示例#1
0
 def export(self, filename):
     reader = YaitronReader(filename)
     for entry in reader.read():
         if entry.lang == self.source_language and entry.translation.lang == self.target_language:
             self.put_li(entry)
             li_id = self.get_li_id(entry)
             self.put_gloss(entry.translation.text, li_id)
示例#2
0
 def export(self, filename):
     reader = YaitronReader(filename)
     for entry in reader.read():
         if entry.lang == self.source_language and entry.translation.lang == self.target_language:
             self.put_li(entry)
             li_id = self.get_li_id(entry)
             self.put_gloss(entry.translation.text, li_id)
import sys
from imp import reload
from yaitron_reader import YaitronReader
reload(sys)

reader = YaitronReader(sys.argv[1])

for entry in reader.read():
    e = entry.to_dict()
    if e["lang"] == u"th":
        print(e["headword"])
示例#4
0
import sys
import sqlite3
from imp import reload
from yaitron_reader import YaitronReader

reload(sys)

reader = YaitronReader("../data/yaitron.xml")
conn = sqlite3.connect("yaitron.sqlite")

c = conn.cursor()

# c.execute('drop table entry');
# c.execute('drop table translation');
c.execute("""create table entry(
  _id integer primary key,
  lang text,
  headword text,
  pos text,
  examples text,
  classifier text,
  definitions text,
  notes text,
  synonyms text,
  antonyms text);""")

c.execute("""create table translation(
  _id integer primary key,
  lang text,
  body text,
  exact boolean,
示例#5
0
import sys
from yaitron_reader import YaitronReader 
reload(sys)        
sys.setdefaultencoding('utf-8')   
reader = YaitronReader(sys.argv[1])

for entry in reader.read():
    e = entry.to_dict()
    if e["lang"] == u"en":
        headword = e["headword"]
        if len(headword.split()) > 1:
            print headword