jeudi 26 mars 2015

how to test if there is any phrase(at least two word) matched the string (sentence) in Python


Vote count:

0




I want to write a python program to test if there are any phrase can match the string using python.



string ='I love traveling all over the world'
word_list =['I love','traveling','all over the world']


So I want to text if there are any one of word_list can match that string that can print 'I love' or 'traveling','all over the world'.



any(x in string for x in word_list)


Or I need to use text mining to solve the problem?



asked 41 secs ago







how to test if there is any phrase(at least two word) matched the string (sentence) in Python

Aucun commentaire:

Enregistrer un commentaire