コード例 #1
0
ファイル: noahpdbdump.py プロジェクト: kjk/noah-palm
def _dumpSimpleData(db):
    fPrintWords = True
    fPrintDefs = False
    toDump = 999999 # -1 means infinity i.e all of them
    print "Record 0:"
    simpleDictData = SimpleDictionaryData(db)
    for name in structhelper.iterlist(simpleFirstRecDef,step=2):
        print "%s: %d" % (name, simpleDictData.getAttr(name))
    print "Record 1: record with word cache"
    _dumpWordCacheRecord(simpleDictData.getWordCacheRecord())
    print "wordsPackStrings"
    _dumpPackStrings(simpleDictData.getWordsPackStrings(),True)
    print "defsPackStrings"
    _dumpPackStrings(simpleDictData.getDefsPackStrings(),True)
    packedStrings = simpleDictData.getWordsPackStrings()
    wordsRecsCount = simpleDictData.getAttr("wordsRecsCount")
    wordNo = 0
    print "wordsRecsCount: %d" % wordsRecsCount
    for word in simpleDictData.getWordsList():
        wordNo += 1
        (offset,l) = simpleDictData.getDefLenOffsetByWord(word)
        if simpleDictData.fHasPosData():
            pos = simpleDictData.getPosByWord(word)
            if fPrintWords and toDump>0:
                #print "%s, %s (%d,%d)" % (word,pos,offset,l)
                print "! (%d) %s (%s)" % (wordNo,word,pos)
        else:
            if fPrintWords and toDump>0:
                print "! %s" % (word)
                #print "%s, (%d,%d)" % (word,offset,l)
        if toDump>0:
            toDump -= 1
        d = simpleDictData.getDefByWord(word)
        if fPrintDefs:
            print d
コード例 #2
0
ファイル: noahpdbdump.py プロジェクト: kjk/noah-palm
def _dumpWnProData(db):
    firstRecData = db.records[0].data
    (firstRec,synCache) = _extractWnProFirstRecordData(firstRecData)
    for name in structhelper.iterlist(wnProFirstRecDef,step=2):
        print "%s: %d" % (name, firstRec[name])
    for s in synCache:
        print "synsetNo=%d, wordsCount=%d" % s
    print "wordsPackStrings"
    _dumpRecWithPackStrings(db.records[2].data)
    print "defsPackStrings"
    _dumpRecWithPackStrings(db.records[3].data)
コード例 #3
0
ファイル: noahpdbdump.py プロジェクト: kjk/noah-palm
def _dumpWnLiteData(db):
    firstRecData = db.records[0].data
    firstRec = _extractWnLiteFirstRecordData(firstRecData)
    for name in structhelper.iterlist(wnLiteFirstRecDef,step=2):
        print "%s: %d" % (name, firstRec[name])