| 106 | }); |
| 107 | |
| 108 | function transformCLI(infoTypes, customInfoTypes) { |
| 109 | infoTypes = infoTypes |
| 110 | ? infoTypes.split(',').map(type => { |
| 111 | return {name: type}; |
| 112 | }) |
| 113 | : undefined; |
| 114 | |
| 115 | if (customInfoTypes) { |
| 116 | customInfoTypes = customInfoTypes.includes(',') |
| 117 | ? customInfoTypes.split(',').map((dict, idx) => { |
| 118 | return { |
| 119 | infoType: {name: 'CUSTOM_DICT_'.concat(idx.toString())}, |
| 120 | dictionary: {wordList: {words: dict.split(',')}}, |
| 121 | }; |
| 122 | }) |
| 123 | : customInfoTypes.split(',').map((rgx, idx) => { |
| 124 | return { |
| 125 | infoType: {name: 'CUSTOM_REGEX_'.concat(idx.toString())}, |
| 126 | regex: {pattern: rgx}, |
| 127 | }; |
| 128 | }); |
| 129 | } |
| 130 | |
| 131 | return [infoTypes, customInfoTypes]; |
| 132 | } |