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