Skip to content

Commit

Permalink
Merge pull request #46 from zalandoresearch/GH-23-retagging-error
Browse files Browse the repository at this point in the history
GH-23: retagging error
  • Loading branch information
tabergma authored Aug 3, 2018
2 parents 9740786 + d57d7e7 commit 446c183
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions flair/models/sequence_tagger_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from typing import List, Tuple, Union

from flair.training_utils import clear_embeddings

START_TAG: str = '<START>'
STOP_TAG: str = '<STOP>'

Expand Down Expand Up @@ -359,6 +361,9 @@ def predict(self, sentences: Union[List[Sentence], Sentence], mini_batch_size=32
if type(sentences) is Sentence:
sentences = [sentences]

# remove previous embeddings
clear_embeddings(sentences)

# make mini-batches
batches = [sentences[x:x + mini_batch_size] for x in range(0, len(sentences), mini_batch_size)]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='flair',
version='0.2.0',
version='0.2.0.post1',
description='A very simple framework for state-of-the-art NLP',
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand Down
17 changes: 17 additions & 0 deletions tests/test_sequence_tagger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from flair.data import Sentence
from flair.models import SequenceTagger


def test_tag_sentence():

# test tagging
sentence = Sentence('I love Berlin')

tagger = SequenceTagger.load('ner')

tagger.predict(sentence)

# test re-tagging
tagger = SequenceTagger.load('pos')

tagger.predict(sentence)

0 comments on commit 446c183

Please sign in to comment.