Fixing bugs in database generation
This commit is contained in:
parent
ea90c4ceb0
commit
8fa4adf71a
@ -86,12 +86,12 @@ def loadDefinitions(path):
|
||||
def parseKanjiDic(path):
|
||||
results = list()
|
||||
|
||||
for line in loadDefinitions('kanjidic'):
|
||||
for line in loadDefinitions(path):
|
||||
segments = line.split()
|
||||
character = segments[0]
|
||||
kunYomi = ','.join(filter(lambda x: filter(isHiragana, x), segments[1:])),
|
||||
onYomi = ','.join(filter(lambda x: filter(isKatakana, x), segments[1:])),
|
||||
meanings = ','.join(re.findall('\{([^\}]+)\}', line))
|
||||
kunYomi = ', '.join(filter(lambda x: filter(isHiragana, x), segments[1:]))
|
||||
onYomi = ', '.join(filter(lambda x: filter(isKatakana, x), segments[1:]))
|
||||
meanings = '; '.join(re.findall('\{([^\}]+)\}', line))
|
||||
results.append((character, onYomi, kunYomi, meanings))
|
||||
|
||||
return results
|
||||
@ -99,8 +99,8 @@ def parseKanjiDic(path):
|
||||
|
||||
def writeKanjiDic(cursor, values):
|
||||
cursor.execute('DROP TABLE IF EXISTS Kanji')
|
||||
cursor.execute('CREATE TABLE Radicals(character TEXT, kunYomi TEXT, onYomi TEXT, meanings TEXT)')
|
||||
cursor.executemany('INSERT INTO Radicals VALUES(?, ?, ?, ?)', values)
|
||||
cursor.execute('CREATE TABLE Kanji(character TEXT, kunYomi TEXT, onYomi TEXT, meanings TEXT)')
|
||||
cursor.executemany('INSERT INTO Kanji VALUES(?, ?, ?, ?)', values)
|
||||
|
||||
|
||||
def parseKradFile(path):
|
||||
|
Loading…
Reference in New Issue
Block a user