Есть два предложения в "test_tweet1.txt"Ошибка: совпадение слов в файле
@francesco_con40 2nd worst QB. DEFINITELY Tony Romo. The man who likes to share the ball with everyone. Including the other team.
@mariakaykay aga tayo tomorrow ah. :) Good night, Ces. Love you! >:D<
В "Personal.txt"
The Game (rapper)
The Notorious B.I.G.
The Undertaker
Thor
Tiësto
Timbaland
T.I.
Tom Cruise
Tony Romo
Trajan
Triple H
Мои коды:
import re
popular_person = open('C:/Users/Personal.txt')
rpopular_person = popular_person.read()
file1 = open("C:/Users/test_tweet1.txt").readlines()
array = []
count1 = 0
for line in file1:
array.append(line)
count1 = count1 + 1
print "\n",count1, line
ltext1 = line.split(" ")
for i,text in enumerate(ltext1):
if text in rpopular_person:
print text
text2 = ' '.join(ltext1)
Результаты от приведенных кодов:
1 @francesco_con40 2nd worst QB. DEFINITELY Tony Romo. The man who likes to share the ball with everyone. Including the other team.
Tony
The
man
to
the
the
2 @mariakaykay aga tayo tomorrow ah. :) Good night, Ces. Love you! >:D<
aga
Я попытался совместить слово с "test_tweet1.txt" с "Personal.txt".
Ожидаемый результат:
Tony
Romo
Любое предложение?
Я пробовал и не работал. Результаты пустые. – ThanaDaray
@ThanaDaray Попробуйте добавить код, посмотрите, дает ли это то, что вы хотите – cmd