python nltk keyword extraction from sentence

后端 未结 3 1094
情话喂你
情话喂你 2021-02-10 03:09

\"First thing we do, let\'s kill all the lawyers.\" - William Shakespeare

Given the quote above, I would like to pull out \"k

3条回答
  •  情歌与酒
    2021-02-10 03:54

    in your case, you can simply use Rake (thanks to Fabian) package for python to get what you need:

    >>> path = #your path 
    >>> r = RAKE.Rake(path)
    >>> r.run("First thing we do, let's kill all the lawyers")
    [('lawyers', 1.0), ('kill', 1.0), ('thing', 1.0)]
    

    the path can be for example this file.

    but in general, you better to use NLTK package for the NLP usages

提交回复
热议问题