match POS tag and sequence of words

后端 未结 5 1741
我寻月下人不归
我寻月下人不归 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:22

    Would this help?

    s1=[('something', 'NN'), ('like', 'IN'), ('how', 'WRB'), ('writer', 'NN'), ('pro', 'NN'), ('or', 'CC'), ('phraseology', 'NN'), ('works', 'NNS'), ('would', 'MD'), ('be', 'VB'), ('really', 'RB'), ('cool', 'JJ'), ('.', '.')]
    
    flag = True
    for i,j in zip(s1[:-1],s1[1:]):
        if i[0]+" "+j[0] == "would be":
            flag = True
        if flag and (i[-1] == "JJ" or j[-1] == "JJ"):
            print "would be adjective found in the tagged string"
    

提交回复
热议问题