コード例 #1
0
ファイル: fromJdict.py プロジェクト: Worthy7/AnkiAddons
def getMeaning(word, isBulk):
    language = japaneseDict.initLanguage()
    
    results, length = language.wordSearch(word, 100, False)
    if not results:
        return
    
    #cheeky get num of results from tanaka
    for i in range(0,len(results)):
        results[i] = results[i] +  (unicode(SNSJsentences.howManyExamples(results[i][0])),)
    
    #build unique dict
    resultsByKey = dict()
    for r in results:
        resultsByKey[(r[0]+' '+ r[1] +'('+ r[5]+')'+ r[2]+' '+ r[3] + ' ' +r[4]) ] = r
       
    
    #(expression, unicode(), glossary, conjugations, source, count)
    if len(results) > 2 and not isBulk:
        resultText = getKeyFromList("JDict", "Multiple results found, please select one!", [(r[0]+' '+ r[1] +'('+ r[5]+')'+ r[2]+' '+ r[3] + ' ' +r[4]) for r in results])
        if resultText == None:
            return results[0]
        return resultsByKey[resultText]
        #return getKeyFromList("JDict", "Multiple results found, please select one!", [[(r[2], r) for r in results],[( r) for r in results]])
    if results:
        return results[0]
コード例 #2
0
def getMeaning(word, isBulk):
    language = japaneseDict.initLanguage()

    results, length = language.wordSearch(word, 100, False)
    if not results:
        return

    #cheeky get num of results from tanaka
    for i in range(0, len(results)):
        results[i] = results[i] + (unicode(
            SNSJsentences.howManyExamples(results[i][0])), )

    #build unique dict
    resultsByKey = dict()
    for r in results:
        resultsByKey[(r[0] + ' ' + r[1] + '(' + r[5] + ')' + r[2] + ' ' +
                      r[3] + ' ' + r[4])] = r

    #(expression, unicode(), glossary, conjugations, source, count)
    if len(results) > 2 and not isBulk:
        resultText = getKeyFromList(
            "JDict", "Multiple results found, please select one!",
            [(r[0] + ' ' + r[1] + '(' + r[5] + ')' + r[2] + ' ' + r[3] + ' ' +
              r[4]) for r in results])
        if resultText == None:
            return results[0]
        return resultsByKey[resultText]
        #return getKeyFromList("JDict", "Multiple results found, please select one!", [[(r[2], r) for r in results],[( r) for r in results]])
    if results:
        return results[0]
コード例 #3
0
    def getBestMeaning(self, word):
        language = japaneseDict.initLanguage()
        
        results, length = language.wordSearch(word, 100, False)
        if not results:
            return
        
        #cheeky get num of results from tanaka
        for i in range(0,len(results)):
            results[i] = results[i] +  (unicode(SNSJsentences.howManyExamples(results[i][0])),)
        
        #build unique dict
        resultsByKey = dict()
        for r in results:
            resultsByKey[r[0]+' '+ r[1] +' '+ r[2]+' '+ r[3]+' '+ r[4] + ' ' +r[5] ] = r

        #WTF no sorting????????
        
        #(expression, unicode(), glossary, conjugations, source, count)
        if results:
            return results[0]