Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> from nltk import*
- >>> def hedge(text):
- count = 0
- for w in range(len(text)):
- if count == 3:
- text[w] = "like"
- count = 0
- count= count + 1
- return text
- >>> import nltk
- >>> f=open("donquijote.txt", "rU")
- >>> quijote=nltk.wordpunct_tokenize(f.read())
- >>> f.close()
- >>> quijotito=quijote[:20]
- >>> hedge(quijotito)
- ['El', 'ingenioso', 'hidalgo', 'like', 'Quijote', 'de', 'like', 'Mancha', 'TASA', 'like', ',', 'Juan', 'like', 'de', 'Andrada', 'like', 'escribano', 'de', 'like', 'del']
- >>>
Add Comment
Please, Sign In to add comment