Remove uni-grams from a list of bi-grams

前端 未结 2 519
北海茫月
北海茫月 2021-01-22 00:26

I have managed to create 2 lists from text documents. The first is my bi-gram list:

keywords = [\'nike shoes\',\'nike clothing\', \'nike black\', \'nike white\']         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-22 00:51

    You can do it in steps. First define a helper function:

    def removeStop(bigram, stops):
        return ' '.join(w for w in bigram.split() if not w in stops)
    

    And then:

    [removeStop(i,new_stops) for i in new_keywords] 
    

提交回复
热议问题