SHARE
TWEET

python homework

a guest Dec 10th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. liste = {"hallo" : "hello" ,"wie" : "how" ,"geht" : "how/well" ,"es" : "it" , "dir": "you"}
  2.  
  3. def tokenize(sentence):
  4.  tokens = []
  5.  for word in sentence.split():
  6.   if word[-1] in ".,!?;":
  7.    tokens.extend([word[:-1], word[-1]])
  8.   else:
  9.    tokens.append(word)
  10.  return tokens
  11.  
  12.  
  13.  
  14.  
  15.  
  16. lang = liste
  17. def detect_pos(sentence):
  18.     shorttoken= tokenize(sentence)
  19.     for i in sentence:
  20.      if lang in shorttoken:
  21.         finden = shorttoken.index(liste.keys(0))
  22.         if liste.values(shorttoken[finden]):
  23.             return "hello"
  24.         elif liste.values(shorttoken[finden +1]):
  25.             return "how"
  26.  
  27.         else: return print("unkown")
  28.  
  29. if __name__ == '__main__':
  30.  
  31.  
  32.  detect_pos("hallo")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top