Repository: flairNLP/flair

Issue:
Integrate Taggers for Historical German by @redewiedergabe
The @redewiedergabe project trained taggers for historical German to detect different types of speech, though and writing representation. 

Full information on these taggers can be found here: https://github.com/redewiedergabe/tagger 

This issue tracks the integration of the "Redewiedergabe" taggers into Flair.


Discussion:

Resolving patch:
diff --git a/flair/models/sequence_tagger_model.py b/flair/models/sequence_tagger_model.py
--- a/flair/models/sequence_tagger_model.py
+++ b/flair/models/sequence_tagger_model.py
@@ -15,7 +15,7 @@
 from flair.data import Dictionary, Sentence, Token, Label, space_tokenizer
 from flair.datasets import SentenceDataset, StringDataset
 from flair.embeddings import TokenEmbeddings
-from flair.file_utils import cached_path
+from flair.file_utils import cached_path, unzip_file
 from flair.training_utils import Metric, Result, store_embeddings
 
 log = logging.getLogger("flair")
@@ -1015,6 +1015,35 @@ def _fetch_model(model_name) -> str:
         if model_name in model_map:
             model_name = cached_path(model_map[model_name], cache_dir=cache_dir)
 
+        # the historical German taggers by the @redewiegergabe project
+        if model_name == "de-historic-indirect":
+            model_file = Path(flair.cache_root)  / cache_dir / 'indirect' / 'final-model.pt'
+            if not model_file.exists():
+                cached_path('http://www.redewiedergabe.de/models/indirect.zip', cache_dir=cache_dir)
+                unzip_file(Path(flair.cache_root)  / cache_dir / 'indirect.zip', Path(flair.cache_root)  / cache_dir)
+            model_name = str(Path(flair.cache_root)  / cache_dir / 'indirect' / 'final-model.pt')
+
+        if model_name == "de-historic-direct":
+            model_file = Path(flair.cache_root)  / cache_dir / 'direct' / 'final-model.pt'
+            if not model_file.exists():
+                cached_path('http://www.redewiedergabe.de/models/direct.zip', cache_dir=cache_dir)
+                unzip_file(Path(flair.cache_root)  / cache_dir / 'direct.zip', Path(flair.cache_root)  / cache_dir)
+            model_name = str(Path(flair.cache_root)  / cache_dir / 'direct' / 'final-model.pt')
+
+        if model_name == "de-historic-reported":
+            model_file = Path(flair.cache_root)  / cache_dir / 'reported' / 'final-model.pt'
+            if not model_file.exists():
+                cached_path('http://www.redewiedergabe.de/models/reported.zip', cache_dir=cache_dir)
+                unzip_file(Path(flair.cache_root)  / cache_dir / 'reported.zip', Path(flair.cache_root)  / cache_dir)
+            model_name = str(Path(flair.cache_root)  / cache_dir / 'reported' / 'final-model.pt')
+
+        if model_name == "de-historic-free-indirect":
+            model_file = Path(flair.cache_root)  / cache_dir / 'freeIndirect' / 'final-model.pt'
+            if not model_file.exists():
+                cached_path('http://www.redewiedergabe.de/models/freeIndirect.zip', cache_dir=cache_dir)
+                unzip_file(Path(flair.cache_root)  / cache_dir / 'freeIndirect.zip', Path(flair.cache_root)  / cache_dir)
+            model_name = str(Path(flair.cache_root)  / cache_dir / 'freeIndirect' / 'final-model.pt')
+
         return model_name
 
     def get_transition_matrix(self):


Test patch: