Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1.  ##if we are only incrementing for every sentence how can we go about incrementing for every word>!>!>!>!>>!>
  2. lpgTxt = (('abcd', 'efgh'), ('abcd', 'ijkl'), ('abcd', 'efgh', 'ijkl', 'mnop'))
  3. max_Sent_Len = 0
  4. Idx2Words = {}
  5. wordList = []
  6. for   sentence in lpgTxt:
  7.     clean_sent = sentence
  8.     word_counter= len(clean_sent)
  9.     # clean_sent = clean_sentence(sentence)
  10.     max_Sent_Len = len(clean_sent) if len(clean_sent) > max_Sent_Len else max_Sent_Len
  11.     # w1,w2 = clean_sent
  12.     word = 0
  13.     while word !=  word_counter:(
  14.         ws = [w for w in clean_sent]
  15.         word+=1)
  16.     if w1 not in wordList:wordList.append(w1)
  17.     if w2 not in wordList: wordList.append(w2)  
  18.     Idx2Words.update( w for w in enumerate(wordList))
  19. Word2Idx = {v:k for k, v in Idx2Words.items()}
  20. print(Word2Idx)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement