How to add tags to negated words in strings that follow “not”, “no” and “never”

后端 未结 3 686
醉话见心
醉话见心 2021-01-03 12:01

How do I add the tag NEG_ to all words that follow not, no and never until the next punctuation mark in a string(used for

3条回答
  •  难免孤独
    2021-01-03 12:26

    I would not do this with regexp. Rather I would;

    • Split the input on punctuation characters.
    • For each fragment do
    • Set negation counter to 0
    • Split input into words
    • For each word
    • Add negation counter number of NEG_ to the word. (Or mod 2, or 1 if greater than 0)
    • If original word is in {No,Never,Not} increase negation counter by one.

提交回复
热议问题