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

integrated tokenizer #47

Closed
attardi opened this issue Oct 17, 2020 · 3 comments
Closed

integrated tokenizer #47

attardi opened this issue Oct 17, 2020 · 3 comments

Comments

@attardi
Copy link

attardi commented Oct 17, 2020

A simple change is needed in order to integrate a tokenizer.
In file utils/transform.py, to method CoNLL.transform.init(), add the optional parameter

reader=open

and then set

self.reader=reader

and in CoNLL.load(), change it to use it:

    if isinstance(data, str):
        if not hasattr(self, 'reader'): self.reader = open # back compatibility       
        with self.reader(data) as f:
            lines = [line.strip() for line in f]

You can then pass as reader a nltk tokenizer or a Stanza tokenizer.
I use this code to interface tp Stanza:

tokenizer.py.txt

@yzhangcs
Copy link
Owner

Could give me some examples.
What do you expect to return if passing a line in which word is tokenized into several pieces?

@attardi
Copy link
Author

attardi commented Oct 18, 2020

I am passing it a plain text, either a file or a string. It invokes the tokenizer for the given language and get the output in CoNLL format for reading by the parser.

I enclose a fix to the code.
tokenizer.py.txt

@yzhangcs
Copy link
Owner

@attardi that's seems feasible.

yzhangcs added a commit that referenced this issue Mar 16, 2021
yzhangcs added a commit that referenced this issue Apr 14, 2021
yzhangcs added a commit that referenced this issue Jun 14, 2021
yzhangcs added a commit that referenced this issue Jun 14, 2021
yzhangcs added a commit that referenced this issue Dec 26, 2021
yzhangcs added a commit that referenced this issue Apr 1, 2022
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

No branches or pull requests

2 participants