Guest User

Untitled

a guest
Jul 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1.  
  2. >>> from nltk import*
  3. >>> def hedge(text):
  4. count = 0
  5. for w in range(len(text)):
  6. if count == 3:
  7. text[w] = "like"
  8. count = 0
  9. count= count + 1
  10. return text
  11.  
  12. >>> import nltk
  13. >>> f=open("donquijote.txt", "rU")
  14. >>> quijote=nltk.wordpunct_tokenize(f.read())
  15. >>> f.close()
  16. >>> quijotito=quijote[:20]
  17. >>> hedge(quijotito)
  18. ['El', 'ingenioso', 'hidalgo', 'like', 'Quijote', 'de', 'like', 'Mancha', 'TASA', 'like', ',', 'Juan', 'like', 'de', 'Andrada', 'like', 'escribano', 'de', 'like', 'del']
  19. >>>
Add Comment
Please, Sign In to add comment