Research Article
DPAEG: A Dependency Parse-Based Adversarial Examples Generation Method for Intelligent Q&A Robots
Algorithm 1
Keywords extraction algorithm.
Input: original question | Output: keywords set K | (1) | Initialize a keywords set K, a stack S, and a word P | (2) | = dependency parser () | (3) | Push the head of the question into the stack S | (4) | While S is not empty do | (5) | Pop the top of the stack S to the word P | (6) | if is content word then | (7) | Add P to keyword set K | (8) | end if | (9) | for child nodes of P do | (10) | if and is a content word then | (11) | Add to keyword set K | (12) | end if | (13) | if is modified by a clause then | (14) | Push the head of the clause into the stack S | (15) | end if | (16) | end for | (17) | end while | (18) | return keywords set K |
|