#!python
#  -*- coding: UTF-8 -*-

from tnthai.swathclone.SC import SwathC
from tnthai.swathclone.SC import SwathDicTrie 
from tnthai.swathclone.SC import SwathSegmentAlgorithm 
import json ,sys

# initialize segmenter to call class in SC
WordSegment = SwathC(SwathDicTrie,SwathSegmentAlgorithm)

# recieve text from command line
text = sys.argv[1]

# check if no mode
if (len(sys.argv)-1) != 2:       
    result = WordSegment.Segment(text,"Smart") 
elif sys.argv[2]:
    mode = sys.argv[2]
    result = WordSegment.Segment(text,mode) 

# put result to json type
# jsonResult = {}
# jsonResult["Mode"] = result[0]
# Solutions = []
# for segs in result[1]:
#     res = []
#     for seg in segs:
#         res.append(seg)
#     Solutions.append(res)
# jsonResult["Solutions"]=Solutions

print (result)
# print (json.dumps(jsonResult,ensure_ascii=False))


