Skip to content

Commit

Permalink
Update POS model weights compatible with newest pytorch
Browse files Browse the repository at this point in the history
  • Loading branch information
hvingelby committed Feb 21, 2020
1 parent 137cf52 commit c35ae68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
6 changes: 2 additions & 4 deletions danlp/download.py
Expand Up @@ -94,8 +94,8 @@
# POS MODELS
'flair.pos': {
'url': DANLP_S3_URL + '/models/flair.pos.zip',
'md5_checksum': 'b9892d4c1c654503dff7e0094834d6ed',
'size': 426404955,
'md5_checksum': '627321171ecf4f7933b5e10602a60cbe',
'size': 424727006,
'file_extension': '.pt'
},

Expand Down Expand Up @@ -334,5 +334,3 @@ def _extract_single_file_from_zip(cache_dir: str, file_in_zip: str, full_path, z
os.rename(outpath, full_path)

shutil.rmtree(tmp_path)


30 changes: 15 additions & 15 deletions tests/test_pos_taggers.py
Expand Up @@ -9,21 +9,21 @@
class TestPosTaggers(unittest.TestCase):
def test_flair_tagger(self):
pass
# # Download model beforehand
# download_model('flair.pos', DEFAULT_CACHE_DIR, process_func=_unzip_process_func, verbose=True)
# print("Downloaded the flair model")
#
# # Load the POS tagger using the DaNLP wrapper
# flair_model = load_pos_tagger_with_flair()
#
# # Using the flair POS tagger
# sentence = Sentence('jeg hopper på en bil som er rød sammen med Jens-Peter E. Hansen')
# flair_model.predict(sentence)
#
# expected_string = "jeg <PRON> hopper <VERB> på <ADP> en <DET> bil <NOUN> som <ADP> er " \
# "<AUX> rød <ADJ> sammen <ADV> med <ADP> Jens-Peter <PROPN> E. <PROPN> Hansen <PROPN>"
#
# self.assertEqual(sentence.to_tagged_string(), expected_string)
# Download model beforehand
#download_model('flair.pos', DEFAULT_CACHE_DIR, process_func=_unzip_process_func, verbose=True)
#print("Downloaded the flair model")

# Load the POS tagger using the DaNLP wrapper
flair_model = load_pos_tagger_with_flair()

# Using the flair POS tagger
sentence = Sentence('jeg hopper på en bil som er rød sammen med Jens-Peter E. Hansen')
flair_model.predict(sentence)

expected_string = "jeg <PRON> hopper <VERB> på <ADP> en <DET> bil <NOUN> som <ADP> er " \
"<AUX> rød <ADJ> sammen <ADV> med <ADP> Jens-Peter <PROPN> E. <PROPN> Hansen <PROPN>"

self.assertEqual(sentence.to_tagged_string(), expected_string)


if __name__ == '__main__':
Expand Down

0 comments on commit c35ae68

Please sign in to comment.