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

Fix alignment algorithm #123

Merged
merged 13 commits into from
Apr 21, 2020
Merged

Conversation

tamuhey
Copy link
Contributor

@tamuhey tamuhey commented Jan 2, 2020

From #87

FIx the below method with pytokenizations, which is I created for this purpose.

def _align(self, segment, wp_tokens, *, offset=0):

This library is based on "shortest edit script" and can handle noisy tokenizations, for example:

a = ["げん", "ご"]
b = ["けんこ"] # all accents are dropped (が -> か, ご -> こ)
a2b = [[0], [0]]
b2a = [[0, 1]]
assert tokenizations.get_alignments(a, b) == (a2b, b2a)

(I thinks this library is useful for spacy.align function. see explosion/spaCy#4554)

@tamuhey
Copy link
Contributor Author

tamuhey commented Jan 5, 2020

@tamuhey
Copy link
Contributor Author

tamuhey commented Jan 6, 2020

I created PR in spacy: explosion/spaCy#4878

@honnibal honnibal merged commit 8fbcbd5 into explosion:master Apr 21, 2020
@tamuhey tamuhey deleted the apply-pytokenizations branch May 12, 2020 02:07
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