コード例 #1
0
def matchfromword(word):
    match(extractendings(words[word]))
コード例 #2
0
def matchfromentry(entry):
    match(extractendings(entry))
コード例 #3
0
# full data dict. has trad. as key

from convertpy import extractendings


def gettrad(entry):
    return entry.split()[0]


cedict = open("cedictsubset.txt", encoding="utf-8")
words = {}  # key is traditional characters
matches = {}  # key is word endings

for line in cedict:
    trad = gettrad(line)
    endings = extractendings(line)
    words[trad] = line.strip()
    if endings in matches:
        matches[endings] += " " + trad
    else:
        matches[endings] = trad


def match(endings):
    for match in matches[endings].split():
        print(words[match])


def matchfromentry(entry):
    match(extractendings(entry))
コード例 #4
0
ファイル: builddict.py プロジェクト: reddress/shared
def matchfromword(word):
    match(extractendings(words[word]))
コード例 #5
0
ファイル: builddict.py プロジェクト: reddress/shared
def matchfromentry(entry):
    match(extractendings(entry))
コード例 #6
0
ファイル: builddict.py プロジェクト: reddress/shared
# build Python dictionaries mapping endings to list of matching words
# full data dict. has trad. as key

from convertpy import extractendings

def gettrad(entry):
    return entry.split()[0]
    
cedict = open("cedictsubset.txt", encoding="utf-8")
words = {}    # key is traditional characters
matches = {}  # key is word endings

for line in cedict:
    trad = gettrad(line)
    endings = extractendings(line)
    words[trad] = line.strip()
    if endings in matches:
        matches[endings] += " " + trad
    else:
        matches[endings] = trad

def match(endings):
    for match in matches[endings].split():
        print(words[match])

def matchfromentry(entry):
    match(extractendings(entry))

def matchfromword(word):
    match(extractendings(words[word]))
    # for simplified, use try block, first attempting trad, then