首先nltk_cli
按照说明安装:https ://github.com/alvations/nltk_cli
然后,这是中的一个秘密函数nltk_cli
,也许您会发现它很有用:
alvas@ubi:~/git/nltk_cli$ cat infile.txt
something like how writer pro or phraSEOlogy works would be really cool .
more options like the Syntax editor would be nice
alvas@ubi:~/git/nltk_cli$ python senna.py --chunk2 VP+ADJP infile.txt
would be really cool
would be nice
为了说明其他可能的用法:
alvas@ubi:~/git/nltk_cli$ python senna.py --chunk2 VP+VP infile.txt
!!! NO CHUNK of VP+VP in this sentence !!!
!!! NO CHUNK of VP+VP in this sentence !!!
alvas@ubi:~/git/nltk_cli$ python senna.py --chunk2 NP+VP infile.txt
how writer pro or phraSEOlogy works would be
the Syntax editor would be
alvas@ubi:~/git/nltk_cli$ python senna.py --chunk2 VP+NP infile.txt
!!! NO CHUNK of VP+NP in this sentence !!!
!!! NO CHUNK of VP+NP in this sentence !!!
然后,如果您要检查句子中的短语并输出True / False,只需读取并遍历输出nltk_cli
并检查if-else
条件即可。