예제 #1
0
파일: chvar.py 프로젝트: buganini/chvar
	def transliterate(self, k, cat):
		ret = k
		gk = k
		c = Bsdconv("bsdconv:{0}".format(cat))
		c.conv(p01(k))
		if not c.counter("OERR"):
			return ret
		for layer in self.layers:
			gk = layer[0].rdata.get(gk)
			t = layer[1].get(gk).get(cat, None)
			if t:
				ret = t
				break
			else:
				gk = layer[0].rdata.get(gk, None)
		return ret
예제 #2
0
파일: mkbonus.py 프로젝트: godfat/bsdconv
		continue
	if l.startswith("#"):
		clist.write(l+"\n")
		plist.write(l+"\n")
	a = sep.split(l)
	p = a[0]
	ln = len(p.decode("utf-8"))
	if ln > 1:
		bonus = 6
		p = bcv_zhtw.conv(p).rstrip(",")
		of = plist
	else:
		try:
			bonus = int(a[1])
		except:
			bonus = 0
		sc.counter_reset()
		sc.conv(p)
		score = sc.counter("SCORE")
		if score < 5*ln:
			bonus += 5*ln - score
		if bonus == 0:
			continue
		p = bcv.conv(p).rstrip(",")
		of = clist
	of.write("%s\t?%02X,%s\n" % (p, bonus, p))

f.close()
clist.close()
plist.close()
예제 #3
0
    if o != r:
        print("Test failed at %s" % repr([c, i, o]))
        print("expected(%d): %s" % (len(o), repr(o)))
        print("result(%d): %s" % (len(r), repr(r)))
        passed = False
    del p

for c, d, i in countertest:
    p = Bsdconv(c)
    if not p:
        print(Bsdconv.error())
        print("Test failed at %s" % repr([c, i, o]))
        passed = False
        continue
    p.conv(d)
    r = p.counter()
    for k in i:
        if i[k] != r[k]:
            print("Test failed at %s" % repr([c, d, i]))
            print("expected: %s" % repr(i))
            print("result: %s" % repr(r))
            passed = False
    del p

url = ""
f_map = open("tmp/map.txt")
for l in f_map:
    l = l.strip().split("\t")
    if l[0] == "NormalizationTest.txt":
        url = l[1]
        break
예제 #4
0
		continue
	if l.startswith("#"):
		clist.write(l+"\n")
		plist.write(l+"\n")
	a = sep.split(l)
	p = a[0]
	ln = len(p.decode("utf-8"))
	if ln > 1:
		bonus = 6
		p = bcv_zhtw.conv(p).rstrip(",")
		of = plist
	else:
		try:
			bonus = int(a[1])
		except:
			bonus = 0
		sc.counter_reset()
		sc.conv(p)
		score = sc.counter("SCORE")
		if score < 5*ln:
			bonus += 5*ln - score
		if bonus == 0:
			continue
		p = bcv.conv(p).rstrip(",")
		of = clist
	of.write("%s\t?%02X,%s\n" % (p, bonus, p))

f.close()
clist.close()
plist.close()
예제 #5
0
#!/usr/bin/env python
import sys
from bsdconv import Bsdconv

p=Bsdconv(sys.argv[1])
if not p:
	print(Bsdconv.error())
	del p
	sys.exit()
p.init()
s=sys.stdin.read(1024)
while s:
	print(p.conv_chunk(s),)
	s=sys.stdin.read(1024)

print(p.conv_chunk_last(s))
print('====================================')
print(p.counter())
del p
예제 #6
0
#!/usr/bin/env python
import sys
from bsdconv import Bsdconv

p = Bsdconv(sys.argv[1])
if not p:
    print(Bsdconv.error())
    del p
    sys.exit()
p.conv_file(sys.argv[2], sys.argv[3])
print(p)
print(p.counter())
del p
예제 #7
0
	if o != r:
		print("Test failed at %s" % repr([c, i, o]))
		print("expected(%d): %s" % (len(o), repr(o)))
		print("result(%d): %s" % (len(r), repr(r)))
		passed=False
	del p

for c, d, i in countertest:
	p=Bsdconv(c)
	if not p:
		print(Bsdconv.error())
		print("Test failed at %s" % repr([c, i, o]))
		passed=False
		continue
	p.conv(d)
	r=p.counter()
	for k in i:
		if i[k] != r[k]:
			print("Test failed at %s" % repr([c, d, i]))
			print("expected: %s" % repr(i))
			print("result: %s" % repr(r))
			passed=False
	del p

url=""
f_map=open("tmp/map.txt")
for l in f_map:
	l=l.strip().split("\t")
	if l[0]=="NormalizationTest.txt":
		url=l[1]
		break