File: test_common.py

package info (click to toggle)
tomoe 0.6.0-1.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 51,396 kB
  • sloc: xml: 1,387,526; ansic: 11,515; sh: 9,072; ruby: 1,344; python: 762; makefile: 450
file content (29 lines) | stat: -rw-r--r-- 935 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# encoding: utf-8
import glob
import os
import sys
import unittest
top_dir = os.path.join ('..', '..')
sys.path.insert(0, os.path.join(top_dir, 'bindings', 'python', '.libs'))
import tomoe
tomoe.tomoe_dict_set_default_module_dir(os.path.join(top_dir, 'module', 'dict', '.libs'))
tomoe.tomoe_recognizer_set_default_module_dir(os.path.join(top_dir,  'module', 'recognizer', '.libs'))
data_dir = os.path.join(top_dir, 'data')
test_data_dir = os.path.join(top_dir, 'test', 'data')

def parseStrokeData(file):
    writing = tomoe.Writing()
    lines = open(file, 'r').readlines()
    results = lines.pop(0)
    for line in lines:
        points = line.split(',')
        first_point = points.pop(0)
        x, y = first_point.split()
        writing.move_to(int(x), int(y))
        for point in points:
            x, y = point.split()
            writing.line_to(int(x), int(y))

    return results, writing

# vi:ts=4:nowrap:ai:expandtab