Example #1
0
    def POST(self):
        rawData = cherrypy.request.body.read(int(cherrypy.request.headers['Content-Length']))
        data = json.loads(rawData)
        input = data["text"]

        input = preprocess_input(input)
        open("input.txt", "w").write(input.encode("utf-8"))

        os.system("java -classpath ../JVnSegmenter/dist/JVnSegmenter.jar JVnSegmenter.JVnSegmenter -modeldir ../JVnSegmenter/models -inputfile input.txt; mv input.txt.wseg output.txt")

        result = open("output.txt", "r").read()
        result = postprocess_output(result)
        return json.dumps({"result": result}, ensure_ascii=False)
Example #2
0
 def POST(self):
     rawData = cherrypy.request.body.read(
         int(cherrypy.request.headers['Content-Length']))
     data = json.loads(rawData)
     input = data["text"]
     input = preprocess_input(input)
     open("input.txt", "w").write(input.encode("utf-8"))
     # call endpoint
     os.system(
         "cd /royvntokenizer/Roy_VnTokenizer/scripts; python vn_tokenizer.py /royvntokenizer/service/input.txt /royvntokenizer/service/output.txt"
     )
     result = open("output.txt", "r").read()
     result = postprocess_output(result)
     return json.dumps({"result": result}, ensure_ascii=False)
Example #3
0
 def test_preprocess_input_1(self):
     input = u"ngày 13/3"
     expected = u"ngày 13 / 3"
     actual = preprocess_input(input)
     self.assertEqual(expected, actual)
Example #4
0
 def test_preprocess_input_3(self):
     input = u"Ngày 13/3, các quận nội thành Hà Nội tiếp tục ra quân xử lý lấn chiếm vỉa hè, lòng đường."
     expected = u"Ngày 13 / 3 ,  các quận nội thành Hà Nội tiếp tục ra quân xử lý lấn chiếm vỉa hè ,  lòng đường . "
     actual = preprocess_input(input)
     print actual
     self.assertEqual(expected, actual)
Example #5
0
 def test_preprocess_input_2(self):
     input = u"vỉa hè,"
     expected = u"vỉa hè , "
     actual = preprocess_input(input)
     self.assertEqual(expected, actual)