Ejemplo n.º 1
0
def search(text):
    # Takes text and runs tokenize() and then runs headword()
    output = []
    jdict = EDICT()
    tokens = tokenize(text)
    for t in tokens:
        defs = jdict.getFor(t[0])
        for line in defs:
            line = ''.join(line)
            output.append(line)

    return output
Ejemplo n.º 2
0
def search(text):
    # Takes text and runs tokenize() and then runs headword()
    output = []
    jdict = EDICT()
    tokens = tokenize(text)
    for t in tokens:
        defs = jdict.getFor(t[0])
        for line in defs:
            line = ''.join(line)
            output.append(line)

    return output
Ejemplo n.º 3
0
def trydef(text):
    jdict = EDICT()
    jdict.db.registerUnicode = True

    output = []
    outdict = jdict.getForHeadword(text)
    for line in outdict:
        output.append(line)
    if len(output) < 1:
        output = []
        outdict = jdict.getForReading(text)
        for line in outdict:
            output.append(line)
    return output
Ejemplo n.º 4
0
def trydef(text):
    jdict = EDICT()
    jdict.db.registerUnicode = True

    output = []
    outdict = jdict.getForHeadword(text)
    for line in outdict:
        output.append(line)
    if len(output) < 1:
        output = []
        outdict = jdict.getForReading(text)
        for line in outdict:
            output.append(line)
    return output
Ejemplo n.º 5
0
def sentGloss(res, t):
    """
        Fall back to reading-based Japanese lookup
        if headword lookup fails. Chinese lookup
        multi-pronged by default.
        """               
    if t == SGJ:
        from cjklib.dictionary import EDICT    
        d = EDICT()
        dtrans = d.getForHeadword(res)    
    elif t == SGC or t == SGCW: 
        from cjklib.dictionary import CEDICT
        d = CEDICT()
        if res in cedict.all:
            dtrans = d.getFor(res)
        else: return ''
    entries = [] 
    entry = ''
    for e in dtrans:
        for f in e._fields:
            if getattr(e, f) != None:
                entry = unicode(getattr(e, f)) + u'\t'
                entries.append(entry)
    if len(entries) == 0:
        for e in d.getForReading(res):
            for f in e._fields:
                if getattr(e, f) != None:
                    entry = unicode(getattr(e, f)) + u'\t'
                    entries.append(entry)
    return u'\t'.join(entries)
Ejemplo n.º 6
0
def search(text):
    # Takes text and runs tokenize() and then runs headword()
    output = []
    jdict = EDICT()
    tokens = tokenize(text)
    for t in tokens:
        defs = jdict.getFor(t[0])
        for line in defs:
            line = ''.join(line)
            output.append(line)

    return output


jdict = EDICT()


def trydef(text):
    jdict = EDICT()
    jdict.db.registerUnicode = True

    output = []
    outdict = jdict.getForHeadword(text)
    for line in outdict:
        output.append(line)
    if len(output) < 1:
        output = []
        outdict = jdict.getForReading(text)
        for line in outdict:
            output.append(line)