Research Article
DPAEG: A Dependency Parse-Based Adversarial Examples Generation Method for Intelligent Q&A Robots
Algorithm 2
Adversarial words generation algorithm.
Input: keyword k | Output: adversarial word set | (1) | //Query typos of keyword k | (2) | if there are typos of keyword k in the typos corpus and then | (3) | Add typos of keyword k to | (4) | end if | (5) | //Search for spell-similar words | (6) | Set the value of d according to the POS of k | (7) | Determine the subdictionary according to the initials of the keyword k | (8) | for do | (9) | if the word satisfies three constraints then | (10) | Add similar word to similar word set | (11) | end if | (12) | end for | (13) | //Query typos of spell-similar words | (14) | for do | (15) | if then | (16) | Add to | (17) | else | (18) | if there are typos of in the typos corpus and then | (19) | Add typos of to | (20) | end if | (21) | end if | (22) | end for | (23) | return adversarial words set |
|