# Path: visualize.py
# def read_conll(inp,maxsent):
#     """ Read conll format file and yield one sentence at a time as a list of lists of columns. If inp is a string it will be interpreted as filename, otherwise as open file for reading in unicode"""
#     if isinstance(inp,basestring):
#         f=codecs.open(inp,u"rt",u"utf-8")
#     else:
#         f=codecs.getreader("utf-8")(sys.stdin) # read stdin
#     count=0
#     sent=[]
#     comments=[]
#     for line in f:
#         line=line.strip()
#         if not line:
#             if sent:
#                 count+=1
#                 yield sent, comments
#                 if maxsent!=0 and count>=maxsent:
#                     break
#                 sent=[]
#                 comments=[]
#         elif line.startswith(u"#"):
#             if sent:
#                 raise ValueError("Missing newline after sentence")
#             comments.append(line)
#             continue
#         else:
#             sent.append(line.split(u"\t"))
#     else:
#         if sent:
#             yield sent, comments
# 
#     if isinstance(inp,basestring):
#         f.close() #Close it if you opened it


from visualize import read_conll
import codecs
import json
import os.path
    import argparse
    import compat.argparse as argparse
try:
except ImportError:

def print_sent(sent,comments):
    if comments:
        print (u"\n".join(comments)).encode(u"utf-8")
    print (u"\n".join(u"\t".join(cols) for cols in sent)).encode(u"utf-8")

parser = argparse.ArgumentParser(description='Options')
parser.add_argument('-d', required=True, help='Where to read the comments?')
args = parser.parse_args()

comms=None
if os.path.isfile(args.d):
    with open(args.d,"r") as f:
        comms=json.load(f)

sent_count=0

# Path: visualize.py
# def read_conll(inp,maxsent):
#     """ Read conll format file and yield one sentence at a time as a list of lists of columns. If inp is a string it will be interpreted as filename, otherwise as open file for reading in unicode"""
#     if isinstance(inp,basestring):
#         f=codecs.open(inp,u"rt",u"utf-8")
#     else:
#         f=codecs.getreader("utf-8")(sys.stdin) # read stdin
#     count=0
#     sent=[]
#     comments=[]
#     for line in f:
#         line=line.strip()
#         if not line:
#             if sent:
#                 count+=1
#                 yield sent, comments
#                 if maxsent!=0 and count>=maxsent:
#                     break
#                 sent=[]
#                 comments=[]
#         elif line.startswith(u"#"):
#             if sent:
#                 raise ValueError("Missing newline after sentence")
#             comments.append(line)
#             continue
#         else:
#             sent.append(line.split(u"\t"))
#     else:
#         if sent:
#             yield sent, comments
# 
#     if isinstance(inp,basestring):
#         f.close() #Close it if you opened it


# Path: add_comments.py
from visualize import read_conll
import codecs
import json
import os.path
    import argparse
    import compat.argparse as argparse

try:
except ImportError:

def print_sent(sent,comments):
    if comments:
        print (u"\n".join(comments)).encode(u"utf-8")
    print (u"\n".join(u"\t".join(cols) for cols in sent)).encode(u"utf-8")

parser = argparse.ArgumentParser(description='Options')
parser.add_argument('-d', required=True, help='Where to read the comments?')
args = parser.parse_args()

comms=None
if os.path.isfile(args.d):
    with open(args.d,"r") as f:
        comms=json.load(f)

sent_count=0

for sent,comments in read_conll(None,0):