Skip to content

Commit a25e2e4

Browse files
committed
Move default value to translation result
1 parent ac72dc0 commit a25e2e4

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

machine/jobs/nmt_engine_build_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _batch_inference(
115115
check_canceled()
116116
for i, result in enumerate(engine.translate_batch(seg_batch)):
117117
pretranslations[current_inference_step + i]["translation"] = result.translation
118-
pretranslations[current_inference_step + i]["sequenceConfidence"] = result.sequence_confidence or -1
118+
pretranslations[current_inference_step + i]["sequenceConfidence"] = result.sequence_confidence
119119
current_inference_step += len(seg_batch)
120120
phase_progress(ProgressStatus.from_step(current_inference_step, inference_step_count))
121121

machine/translation/translation_result.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterable, Optional, Sequence
1+
from typing import Iterable, Sequence
22

33
from .phrase import Phrase
44
from .translation_sources import TranslationSources
@@ -12,7 +12,7 @@ def __init__(
1212
source_tokens: Iterable[str],
1313
target_tokens: Iterable[str],
1414
confidences: Iterable[float],
15-
sequence_confidence: Optional[float],
15+
sequence_confidence: float,
1616
sources: Iterable[TranslationSources],
1717
alignment: WordAlignmentMatrix,
1818
phrases: Iterable[Phrase],
@@ -52,7 +52,7 @@ def confidences(self) -> Sequence[float]:
5252
return self._confidences
5353

5454
@property
55-
def sequence_confidence(self) -> Optional[float]:
55+
def sequence_confidence(self) -> float:
5656
return self._sequence_confidence
5757

5858
@property

machine/translation/translation_result_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(
2828
self._confidences: List[float] = []
2929
self._sources: List[TranslationSources] = []
3030
self._phrases: List[PhraseInfo] = []
31-
self._sequence_confidence: Optional[float] = None
31+
self._sequence_confidence: float = -1.0
3232

3333
@property
3434
def source_tokens(self) -> Sequence[str]:
@@ -51,7 +51,7 @@ def phrases(self) -> Sequence[PhraseInfo]:
5151
return self._phrases
5252

5353
@property
54-
def sequence_confidence(self) -> Optional[float]:
54+
def sequence_confidence(self) -> float:
5555
return self.sequence_confidence
5656

5757
def append_token(self, token: str, source: TranslationSources, confidence: float) -> None:

0 commit comments

Comments
 (0)