| 106 | } |
| 107 | |
| 108 | static TIntrusivePtr<TBpeDictionary> BuildBpeWord( |
| 109 | const TDictionaryBuilderOptions& dictionaryBuilderOptions, |
| 110 | const TDictionaryOptions& dictionaryOptions, |
| 111 | const TBpeDictionaryOptions& bpeOptions, |
| 112 | const TString& inputFilePath, |
| 113 | const TTokenizerOptions& tokenizerOptions, |
| 114 | bool useTokenizer, |
| 115 | bool verbose |
| 116 | ) { |
| 117 | if (verbose) { |
| 118 | Cerr << "Stage [1/2]: Dictionary building\n"; |
| 119 | } |
| 120 | |
| 121 | auto dictionary = BuildDictionary( |
| 122 | inputFilePath, |
| 123 | dictionaryBuilderOptions, |
| 124 | dictionaryOptions, |
| 125 | tokenizerOptions, |
| 126 | useTokenizer, |
| 127 | verbose |
| 128 | ); |
| 129 | |
| 130 | TBpeDictionaryBuilder bpeBuilder(bpeOptions.NumUnits, bpeOptions.SkipUnknown, dictionary); |
| 131 | |
| 132 | if (verbose) { |
| 133 | Cerr << "Stage [2/2]: Bpe building\n"; |
| 134 | } |
| 135 | |
| 136 | ApplyFuncTotokenizedText( |
| 137 | inputFilePath, |
| 138 | tokenizerOptions, |
| 139 | useTokenizer, |
| 140 | verbose, |
| 141 | [&](const TVector<TString>& tokens) { |
| 142 | bpeBuilder.Add(tokens, /*weight*/1); |
| 143 | } |
| 144 | ); |
| 145 | |
| 146 | return bpeBuilder.FinishBuilding(); |
| 147 | } |
| 148 | |
| 149 | static TIntrusivePtr<TBpeDictionary> BuildBpeLetter( |
| 150 | const TDictionaryBuilderOptions& dictionaryBuilderOptions, |
no test coverage detected