Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##if we are only incrementing for every sentence how can we go about incrementing for every word>!>!>!>!>>!>
- lpgTxt = (('abcd', 'efgh'), ('abcd', 'ijkl'), ('abcd', 'efgh', 'ijkl', 'mnop'))
- max_Sent_Len = 0
- Idx2Words = {}
- wordList = []
- for sentence in lpgTxt:
- clean_sent = sentence
- word_counter= len(clean_sent)
- # clean_sent = clean_sentence(sentence)
- max_Sent_Len = len(clean_sent) if len(clean_sent) > max_Sent_Len else max_Sent_Len
- # w1,w2 = clean_sent
- word = 0
- while word != word_counter:(
- ws = [w for w in clean_sent]
- word+=1)
- if w1 not in wordList:wordList.append(w1)
- if w2 not in wordList: wordList.append(w2)
- Idx2Words.update( w for w in enumerate(wordList))
- Word2Idx = {v:k for k, v in Idx2Words.items()}
- print(Word2Idx)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement