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

Simplify data fetchers #65

Closed
alanakbik opened this issue Aug 14, 2018 · 1 comment
Closed

Simplify data fetchers #65

alanakbik opened this issue Aug 14, 2018 · 1 comment

Comments

@alanakbik
Copy link
Collaborator

There is a lot of redundant code in the data fetcher helper routines. Simplify by creating a generic 'CoNLL-column' data reader that can be passed the column definition, so it is applicable to CoNLL03, CoNLL2000 and any other sequence labeling data that is formatted in a similar column style.

alanakbik pushed a commit that referenced this issue Aug 14, 2018
alanakbik pushed a commit that referenced this issue Aug 14, 2018
tabergma added a commit that referenced this issue Aug 14, 2018
GH-65: refactored to generic column format and string enums
@alanakbik
Copy link
Collaborator Author

Data fetchers now simplified. You can read any CoNLL column formatted file by passing a dict that specifies what column is what field.

For instance:

from flair.data_fetcher import NLPTaskDataFetcher

sentences = NLPTaskDataFetcher.read_column_data('/path/to/conll03/data', column_name_map={0: 'text', 3: 'ner'})

for sentence in sentences:
    print(sentence.to_tagged_string()) 

Will read a CoNLL-03 formatted file and map the first column (index 0) to the lexical value of each word (i.e. the token text) and column index 3 as the NER tag.

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

1 participant