Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Article 1. It is not good to eat pizza after midnight
- Article 2. I wouldn't survive a day withouth stackexchange
- Article 3. All of these are just random phrases
- Article 4. To prove if my experiment works.
- Article 5. The red dog jumps over the lazy fox
- from sklearn.feature_extraction.text import CountVectorizer
- vectorizer = CountVectorizer(min_df=1)
- n=0
- while n < 5:
- n = n + 1
- a = ('Article %(number)s' % {'number': n})
- print(a)
- with open("LISR2.txt") as openfile:
- for line in openfile:
- if a in line:
- X=line
- print(vectorizer.fit_transform(X))
- ValueError: Iterable over raw text documents expected, string object received.
- X=("It is not good to eat pizza","I wouldn't survive a day", "All of these")
- print(vectorizer.fit_transform(X))
- (0, 8) 1
- (0, 2) 1
- (0, 11) 1
- (0, 3) 1
- (0, 6) 1
- (0, 4) 1
- (0, 5) 1
- (1, 1) 1
- (1, 9) 1
- (1, 12) 1
- (2, 10) 1
- (2, 7) 1
- (2, 0) 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement