From 4b8e8b7e443753fa67609a9decedc4ddf6a69bb3 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Mon, 14 Oct 2019 15:57:22 +0200
Subject: [PATCH] Updated conll2text.py

---
 tools/conll2text.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/conll2text.py b/tools/conll2text.py
index 0bb7ec8..24ef74b 100755
--- a/tools/conll2text.py
+++ b/tools/conll2text.py
@@ -1,16 +1,20 @@
 #! /usr/bin/python3
 
 import sys
+import random
 
 def printUsageAndExit() :
-  print("Usage : %s file.conllu delimiterSymbol"%sys.argv[0])
+  print("Usage : %s file.conllu"%sys.argv[0], file=sys.stderr)
   exit(1)
 
+def choseDelimiter() :
+  return random.choices(["\n", " "], k=1, weights=[10, 50])[0]
+
 if __name__ == "__main__" :
 
   sys.stdout = open(1, 'w', encoding='utf-8', closefd=False)
 
-  if len(sys.argv) != 3 :
+  if len(sys.argv) != 2 :
     printUsageAndExit()
 
   for line in open(sys.argv[1], encoding='utf-8') :
@@ -18,5 +22,5 @@ if __name__ == "__main__" :
       continue
 
     if line.startswith("# text") :
-      print(line.strip()[9:], end=sys.argv[2])
+      print(line.strip()[9:], end=choseDelimiter())
 
-- 
GitLab