Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding decodeWithByteRanges: string_views into translated-text #18

Merged
merged 2 commits into from
Mar 2, 2021

Conversation

jerinphilip
Copy link

Attempting to solve browsermt/bergamot-translator#25. Might be useful for marian-nmt#775 (?)

Changes test to accommodate the decoded string_views as well. The square-brackets indicate annotations using string_views, constructed by src/tests/sentencepiece_norm.cpp. The test previously for encodeWithByteRanges is modified to include decodeWithByteRanges as well. Once the expected is set to the output, this regression-tests can be modified as well.

Input Text
Äffin
Henry IV
Ç
가
ℌℍ
①
︷
i⁹
¼
Output

Original: [Ä][ff][in]
Decoded: [Ä][ff][in]
Original: [Henry][ IV]
Decoded: [Henry][ IV]
Original: [Ç]
Decoded: [Ç]
Original: [][가]
Decoded: [][ ⁇ ]
Original: [ℌ][ℍ]
Decoded: [H][H]
Original: [①]
Decoded: [1]
Original: [][︷]
Decoded: [][ ⁇ ]
Original: [i][⁹]
Decoded: [i][9]
Original: [][¼]
Decoded: [][1⁄4]

Requesting review.

@jerinphilip jerinphilip requested review from kpu and ugermann February 15, 2021 11:33
bool ignoreEOS) const override {
sentencepiece::SentencePieceText spt;

std::vector<int> spmSentence;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is int the correct type here? Prefer the actual typedef.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be WordIndex

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok you are right, it's std::vector in the SentencePiece source, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants