From 9ebeb1d7e40160826a9f147dff2aafee1f1baf7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martyna=20Wi=C4=85cek?= <martyna.wiacek@ipipan.waw.pl>
Date: Sat, 15 Apr 2023 00:33:19 +0200
Subject: [PATCH] save head and separate predictions in json file by line

---
 combo/data/api.py | 1 +
 combo/predict.py  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/combo/data/api.py b/combo/data/api.py
index deec11f..f25d035 100644
--- a/combo/data/api.py
+++ b/combo/data/api.py
@@ -57,6 +57,7 @@ class Sentence:
         return json.dumps({
             "tokens": [(t.token, t.lemma, t.upostag, t.xpostag, t. feats, t.head, t.deprel) for t in self.tokens],
             # "sentence_embedding": self.sentence_embedding,
+            "head": [t.head for t in self.tokens],
             "relation_distribution_hash": hash,
             "path_file": str(os.path.join(save_relation_distribution_path, hash + '.npz'))
         }, cls=NumpyArrayEncoder)
diff --git a/combo/predict.py b/combo/predict.py
index ef44be2..fe7eb1a 100644
--- a/combo/predict.py
+++ b/combo/predict.py
@@ -136,7 +136,7 @@ class COMBO(predictor.Predictor):
         else:
             if not os.path.exists(self.save_relation_distribution_path):
                 os.makedirs(self.save_relation_distribution_path)
-            return outputs.to_json(self.save_relation_distribution_path)
+            return outputs.to_json(self.save_relation_distribution_path) + "\n"
 
     @staticmethod
     def _to_input_json(sentence: str):
-- 
GitLab