Added Parsing and Evaluation of Lemmas using Tiger Corpus
diff --git a/DeReKo/tiger_turku_evaluate.py b/DeReKo/tiger_turku_evaluate.py
new file mode 100644
index 0000000..96f25be
--- /dev/null
+++ b/DeReKo/tiger_turku_evaluate.py
@@ -0,0 +1,56 @@
+from CoNLL_Annotation import *
+from collections import Counter
+import pandas as pd
+
+
+def eval_lemma(sys, gld):
+    match, err, symbol = 0, 0, []
+    mistakes = []
+    for i, gld_tok in enumerate(gld.tokens):
+        if gld_tok.lemma == sys.tokens[i].lemma:
+            match += 1
+        elif not sys.tokens[i].lemma.isalnum(): # This was added because Turku does not lemmatize symbols (it only copies them) => ERR ((',', '--', ','), 43642)
+            symbol.append(sys.tokens[i].lemma)
+            if sys.tokens[i].word == sys.tokens[i].lemma:
+                match += 1
+            else:
+                err += 1
+        else:
+            err += 1
+            mistakes.append((gld_tok.word, gld_tok.lemma, sys.tokens[i].lemma))
+    return match, err, symbol, mistakes
+    
+
+
+if __name__ == "__main__":
+
+    # Read the Original TiGeR Annotations
+    gld_filename = "/home/daza/datasets/TIGER_conll/tiger_release_aug07.corrected.16012013.conll09"
+    gld_generator = read_conll_generator(gld_filename, token_class=CoNLL09_Token)
+    
+    # Read the Annotations Generated by the Automatic Parser [Turku] 
+    sys_filename = "/home/daza/datasets/TIGER_conll/tiger_turku_parsed.conllu"
+    sys_generator = read_conll_generator(sys_filename, token_class=CoNLLUP_Token)
+    
+    lemma_all_match, lemma_all_err, lemma_all_mistakes = 0, 0, []
+    lemma_all_symbols = []
+    
+    for i, (s,g) in enumerate(zip(sys_generator, gld_generator)):
+        assert len(s.tokens) == len(g.tokens), "Token Mismatch!"
+        lemma_match, lemma_err, lemma_sym, mistakes = eval_lemma(s,g)
+        lemma_all_match += lemma_match
+        lemma_all_err += lemma_err
+        lemma_all_mistakes += mistakes
+        lemma_all_symbols += lemma_sym
+    
+    print(f"Lemma Matches = {lemma_all_match} || Errors = {lemma_all_err} || Symbol Chars = {len(lemma_all_symbols)}")
+    print(f"Lemma Accuracy = {lemma_all_match*100/(lemma_all_match + lemma_all_err)}%")
+    lemma_miss_df = pd.DataFrame(lemma_all_mistakes, columns =['Gold_Word', 'Gold_Lemma', 'Sys_Lemma']).value_counts()
+    lemma_miss_df.to_csv(path_or_buf="LemmaErrors.tsv", sep="\t")
+        
+#         
+#     the_count = Counter(lemma_all_mistakes).most_common(100)
+#     for x in the_count:
+#         print(x)
+
+    
\ No newline at end of file