Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions machine/jobs/translation_file_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
class PretranslationInfo(TypedDict):
corpusId: str # noqa: N815
textId: str # noqa: N815
refs: List[str]
sourceRefs: List[str] # noqa: N815
targetRefs: List[str] # noqa: N815
translation: str
sourceTokens: List[str] # noqa: N815
translationTokens: List[str] # noqa: N815
Expand Down Expand Up @@ -94,7 +95,8 @@ def generator() -> Generator[PretranslationInfo, None, None]:
yield PretranslationInfo(
corpusId=pi["corpusId"],
textId=pi["textId"],
refs=list(pi["refs"]),
sourceRefs=list(pi["sourceRefs"]),
targetRefs=list(pi["targetRefs"]),
translation=pi["translation"],
sourceTokens=list(),
translationTokens=list(),
Expand Down
7 changes: 4 additions & 3 deletions machine/jobs/word_alignment_build_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def _batch_inference(
[
ParallelTextRow(
ii["textId"],
ii["refs"],
ii["refs"],
ii["sourceRefs"],
ii["targetRefs"],
list(self._tokenizer.tokenize(ii["source"])),
list(self._tokenizer.tokenize(ii["target"])),
)
Expand All @@ -132,7 +132,8 @@ def _batch_inference(
word_alignment_info = {
"corpusId": inference_input["corpusId"],
"textId": inference_input["textId"],
"refs": [str(ref) for ref in inference_input["refs"]],
"sourceRefs": [str(ref) for ref in inference_input["sourceRefs"]],
"targetRefs": [str(ref) for ref in inference_input["targetRefs"]],
"sourceTokens": parallel_text_row.source_segment,
"targetTokens": parallel_text_row.target_segment,
"alignment": AlignedWordPair.to_string(word_pairs),
Expand Down
6 changes: 4 additions & 2 deletions machine/jobs/word_alignment_file_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
class WordAlignmentInput(TypedDict):
corpusId: str # noqa: N815
textId: str # noqa: N815
refs: List[str]
sourceRefs: List[str] # noqa: N815
targetRefs: List[str] # noqa: N815
source: str
target: str

Expand Down Expand Up @@ -62,7 +63,8 @@ def get_word_alignment_inputs(self) -> List[WordAlignmentInput]:
WordAlignmentInput(
corpusId=pi["corpusId"],
textId=pi["textId"],
refs=list(pi["refs"]),
sourceRefs=list(pi["sourceRefs"]),
targetRefs=list(pi["targetRefs"]),
source=pi["source"],
target=pi["target"],
)
Expand Down
3 changes: 2 additions & 1 deletion tests/jobs/test_nmt_engine_build_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ def __init__(self, decoy: Decoy) -> None:
PretranslationInfo(
corpusId="corpus1",
textId="text1",
refs=["ref1"],
sourceRefs=["ref1"],
targetRefs=["ref1"],
translation="Por favor, tengo reservada una habitación.",
sourceTokens=[],
translationTokens=[],
Expand Down
3 changes: 2 additions & 1 deletion tests/jobs/test_smt_engine_build_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ def __init__(self, decoy: Decoy) -> None:
PretranslationInfo(
corpusId="corpus1",
textId="text1",
refs=["ref1"],
sourceRefs=["ref1"],
targetRefs=["ref1"],
translation="Por favor, tengo reservada una habitación.",
sourceTokens=[],
translationTokens=[],
Expand Down
9 changes: 6 additions & 3 deletions tests/jobs/test_word_alignment_build_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,24 @@ def __init__(self, decoy: Decoy) -> None:
WordAlignmentInput(
corpusId="corpus1",
textId="text1",
refs=["1"],
sourceRefs=["1"],
targetRefs=["1"],
source="¿Le importaría darnos las llaves de la habitación, por favor?",
target="Would you mind giving us the room keys, please?",
),
WordAlignmentInput(
corpusId="corpus1",
textId="text1",
refs=["2"],
sourceRefs=["2"],
targetRefs=["2"],
source="¿Le importaría cambiarme a otra habitación más tranquila?",
target="Would you mind moving me to another quieter room?",
),
WordAlignmentInput(
corpusId="corpus1",
textId="text1",
refs=["3"],
sourceRefs=["3"],
targetRefs=["3"],
source="Me parece que existe un problema.",
target="I think there is a problem.",
),
Expand Down
Loading