From c35ae68bb3580bbcafe3d6bbd215a39028426d4f Mon Sep 17 00:00:00 2001 From: Rasmus Hvingelby Date: Fri, 21 Feb 2020 15:22:14 +0100 Subject: [PATCH] Update POS model weights compatible with newest pytorch --- danlp/download.py | 6 ++---- tests/test_pos_taggers.py | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/danlp/download.py b/danlp/download.py index f2dd334..762342e 100644 --- a/danlp/download.py +++ b/danlp/download.py @@ -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' }, @@ -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) - - diff --git a/tests/test_pos_taggers.py b/tests/test_pos_taggers.py index 2815633..b05f1b8 100644 --- a/tests/test_pos_taggers.py +++ b/tests/test_pos_taggers.py @@ -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 hopper en bil som er " \ - # " rød sammen med Jens-Peter E. Hansen " - # - # 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 hopper en bil som er " \ + " rød sammen med Jens-Peter E. Hansen " + + self.assertEqual(sentence.to_tagged_string(), expected_string) if __name__ == '__main__':