| 148 | }); |
| 149 | |
| 150 | function transformCLI(infoTypes, customInfoTypes) { |
| 151 | infoTypes = infoTypes |
| 152 | ? infoTypes.split(',').map(type => { |
| 153 | return {name: type}; |
| 154 | }) |
| 155 | : undefined; |
| 156 | |
| 157 | if (customInfoTypes) { |
| 158 | customInfoTypes = customInfoTypes.includes(',') |
| 159 | ? customInfoTypes.split(',').map((dict, idx) => { |
| 160 | return { |
| 161 | infoType: {name: 'CUSTOM_DICT_'.concat(idx.toString())}, |
| 162 | dictionary: {wordList: {words: dict.split(',')}}, |
| 163 | }; |
| 164 | }) |
| 165 | : customInfoTypes.split(',').map((rgx, idx) => { |
| 166 | return { |
| 167 | infoType: {name: 'CUSTOM_REGEX_'.concat(idx.toString())}, |
| 168 | regex: {pattern: rgx}, |
| 169 | }; |
| 170 | }); |
| 171 | } |
| 172 | |
| 173 | return [infoTypes, customInfoTypes]; |
| 174 | } |