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

GH-238: Add french models. #301

Merged
merged 1 commit into from
Dec 12, 2018
Merged
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
9 changes: 9 additions & 0 deletions flair/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,15 @@ def __init__(self, model: str, detach: bool = True, use_cache: bool = True, cach
base_path = 'https://s3.eu-central-1.amazonaws.com/alan-nlp/resources/embeddings-v0.4/lm-sv-large-backward-v0.1.pt'
model = cached_path(base_path, cache_dir=cache_dir)

# French forward
elif model.lower() == 'french-forward' or model.lower() == 'fr-forward':
base_path = 'https://s3.eu-central-1.amazonaws.com/alan-nlp/resources/embeddings/lm-fr-charlm-forward.pt'
model = cached_path(base_path, cache_dir=cache_dir)
# French backward
elif model.lower() == 'french-backward' or model.lower() == 'fr-backward':
base_path = 'https://s3.eu-central-1.amazonaws.com/alan-nlp/resources/embeddings/lm-fr-charlm-backward.pt'
model = cached_path(base_path, cache_dir=cache_dir)

elif not Path(model).exists():
raise ValueError(f'The given model "{model}" is not available or is not a valid path.')

Expand Down
28 changes: 16 additions & 12 deletions flair/models/sequence_tagger_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,78 +568,82 @@ def load(model: str):
'en-ner-conll03-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'ner-fast':
elif model.lower() == 'ner-fast':
base_path = '/'.join([aws_resource_path,
'NER-conll03--h256-l1-b32-experimental--fast-v0.2',
'en-ner-fast-conll03-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'ner-ontonotes':
elif model.lower() == 'ner-ontonotes':
base_path = '/'.join([aws_resource_path,
'NER-ontoner--h256-l1-b32-%2Bcrawl%2Bnews-forward%2Bnews-backward--v0.2',
'en-ner-ontonotes-v0.3.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'ner-ontonotes-fast':
elif model.lower() == 'ner-ontonotes-fast':
base_path = '/'.join([aws_resource_path,
'NER-ontoner--h256-l1-b32-%2Bcrawl%2Bnews-forward-fast%2Bnews-backward-fast--v0.2',
'en-ner-ontonotes-fast-v0.3.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'pos':
elif model.lower() == 'pos':
base_path = '/'.join([aws_resource_path,
'POS-ontonotes--h256-l1-b32-%2Bmix-forward%2Bmix-backward--v0.2',
'en-pos-ontonotes-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'pos-fast':
elif model.lower() == 'pos-fast':
base_path = '/'.join([aws_resource_path,
'POS-ontonotes--h256-l1-b32-%2Bnews-forward-fast%2Bnews-backward-fast--v0.2',
'en-pos-ontonotes-fast-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'frame':
elif model.lower() == 'frame':
base_path = '/'.join([aws_resource_path,
'FRAME-conll12--h256-l1-b8-%2Bnews%2Bnews-forward%2Bnews-backward--v0.2',
'en-frame-ontonotes-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'frame-fast':
elif model.lower() == 'frame-fast':
base_path = '/'.join([aws_resource_path,
'FRAME-conll12--h256-l1-b8-%2Bnews%2Bnews-forward-fast%2Bnews-backward-fast--v0.2',
'en-frame-ontonotes-fast-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'chunk':
elif model.lower() == 'chunk':
base_path = '/'.join([aws_resource_path,
'NP-conll2000--h256-l1-b32-%2Bnews-forward%2Bnews-backward--v0.2',
'en-chunk-conll2000-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'chunk-fast':
elif model.lower() == 'chunk-fast':
base_path = '/'.join([aws_resource_path,
'NP-conll2000--h256-l1-b32-%2Bnews-forward-fast%2Bnews-backward-fast--v0.2',
'en-chunk-conll2000-fast-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'de-pos':
elif model.lower() == 'de-pos':
base_path = '/'.join([aws_resource_path,
'UPOS-udgerman--h256-l1-b8-%2Bgerman-forward%2Bgerman-backward--v0.2',
'de-pos-ud-v0.2.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'de-ner':
elif model.lower() == 'de-ner':
base_path = '/'.join([aws_resource_path,
'NER-conll03ger--h256-l1-b32-%2Bde-fasttext%2Bgerman-forward%2Bgerman-backward--v0.2',
'de-ner-conll03-v0.3.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model.lower() == 'de-ner-germeval':
elif model.lower() == 'de-ner-germeval':
base_path = '/'.join([aws_resource_path,
'NER-germeval--h256-l1-b32-%2Bde-fasttext%2Bgerman-forward%2Bgerman-backward--v0.2',
'de-ner-germeval-v0.3.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

elif model.lower() == 'fr-ner':
base_path = '/'.join([aws_resource_path, 'NER-aij-wikiner-fr-wp3', 'fr-ner.pt'])
model_file = cached_path(base_path, cache_dir=cache_dir)

if model_file is not None:
tagger: SequenceTagger = SequenceTagger.load_from_file(model_file)
return tagger