match POS tag and sequence of words

后端 未结 5 1736
我寻月下人不归
我寻月下人不归 2020-12-22 06:30

I have the following two strings with their POS tags:

Sent1: \"something like how writer pro or phraseology works would be really cool.\"<

5条回答
  •  北海茫月
    2020-12-22 07:13

    First install the nltk_cli as per the instructions: https://github.com/alvations/nltk_cli

    Then, here's a secret function in nltk_cli, maybe you'll find it useful:

    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
    

    To illustrate other possible usage:

    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 !!!
    

    Then if you want to check if the phrase in sentence and output True/False, simply read and iterate through the outputs from nltk_cli and check with if-else conditions.

提交回复
热议问题