| 368 | } |
| 369 | |
| 370 | std::string ConvertLineByMode(const std::string& line) { |
| 371 | WarnIfTextContainsVariationSelector(line.c_str(), line.size()); |
| 372 | const auto convertStart = std::chrono::steady_clock::now(); |
| 373 | std::string output; |
| 374 | if (outputMode == OutputMode::Segmentation) { |
| 375 | // True segmentation-only path: call the segmenter directly without |
| 376 | // running any conversion stage. |
| 377 | const SegmentsPtr& segments = |
| 378 | converter->GetSegmentation()->Segment(std::string_view(line)); |
| 379 | ConversionInspectionResult result; |
| 380 | result.input = line; |
| 381 | result.segments = segments->ToVector(); |
| 382 | output = SerializeSegmentationResultJson(result); |
| 383 | } else if (outputMode == OutputMode::Inspect) { |
| 384 | const ConversionInspectionResult& result = converter->Inspect(line); |
| 385 | output = SerializeInspectionResultJson(result); |
| 386 | } else { |
| 387 | output = converter->Convert(std::string_view(line)); |
| 388 | } |
| 389 | measurement.convertMs += DurationToMilliseconds( |
| 390 | std::chrono::steady_clock::now() - convertStart); |
| 391 | return output; |
| 392 | } |
| 393 | |
| 394 | void ConvertStream(FILE* fin, FILE* fout) { |
| 395 | const int BUFFER_SIZE = 1024 * 1024; |
no test coverage detected