예제 #1
0
def handleSeeWord(word, pos, defs, quotes):
    global g_seeWordDict
    word = convertEntities(word)
    defs = convertEntities(defs)

    add = True
    if -1 != defs.find("&"):
        add = False
        if -1 == defs.find("&?;"):
            print "------------"
            print pos + "   " + word
            print defs
            for q in quotes:
                print convertEntities(q)
        else:
            print "  *"
    if not add:
        return

    if defs.startswith("See "):
        defs = defs[4:].strip()
    else:
        print " Bad See <word> interpretation: %s" % defs

    # get word to see from def
    defs = defs.strip().strip(".").strip()
    # get only first
    seeWord = defs.split(",")[0].strip()
    g_seeWordDict[word] = seeWord
def handleSeeWord(word, pos, defs, quotes):
    global g_seeWordDict
    word = convertEntities(word)
    defs = convertEntities(defs)

    add = True
    if -1 != defs.find("&"):
        add = False
        if -1 == defs.find("&?;"):
            print "------------"
            print pos + "   " + word
            print defs
            for q in quotes:
                print convertEntities(q)
        else:
            print "  *"
    if not add:
        return

    if defs.startswith("See "):
        defs = defs[4:].strip()
    else:
        print " Bad See <word> interpretation: %s" % defs

    # get word to see from def
    defs = defs.strip().strip(".").strip()
    # get only first
    seeWord = defs.split(",")[0].strip()
    g_seeWordDict[word] = seeWord
예제 #3
0
 def setText(self, text, removeEntities=True):
     if removeEntities:
         text = convertEntities(text)
     try:
         text = text.encode("latin-1", "ignore")
     except:
         pass
     self.addParam(Param(paramTextValue, text))
예제 #4
0
def addWord(word, pos, defs, quotes):
    global g_wordsDict, g_dataTxt
    word = convertEntities(word)
    defs = convertEntities(defs)

    ind = defs.find(". See ")
    if ind != -1:
        defs = defs[: ind + 1]

    add = True
    if -1 != defs.find("&"):
        add = False
        if -1 == defs.find("&?;"):
            print "------------"
            print pos + "   " + word
            print defs
            for q in quotes:
                print convertEntities(q)
        else:
            print "  *"

    if not add:
        return

    # save word def
    textToSave = ""
    textToSave += "$" + pos + "\n"
    textToSave += "@" + defs + "\n"
    for q in quotes:
        q = convertEntities(q)
        textToSave += "#" + q + "\n"

    length = len(textToSave)
    offset = len(g_dataTxt)
    pair = [offset, length]

    g_dataTxt += textToSave
    try:
        g_wordsDict[word].append(pair)
    except:
        g_wordsDict[word] = [pair]
def addWord(word, pos, defs, quotes):
    global g_wordsDict, g_dataTxt
    word = convertEntities(word)
    defs = convertEntities(defs)

    ind = defs.find(". See ")
    if ind != -1:
        defs = defs[:ind + 1]

    add = True
    if -1 != defs.find("&"):
        add = False
        if -1 == defs.find("&?;"):
            print "------------"
            print pos + "   " + word
            print defs
            for q in quotes:
                print convertEntities(q)
        else:
            print "  *"

    if not add:
        return

    # save word def
    textToSave = ""
    textToSave += "$" + pos + "\n"
    textToSave += "@" + defs + "\n"
    for q in quotes:
        q = convertEntities(q)
        textToSave += "#" + q + "\n"

    length = len(textToSave)
    offset = len(g_dataTxt)
    pair = [offset, length]

    g_dataTxt += textToSave
    try:
        g_wordsDict[word].append(pair)
    except:
        g_wordsDict[word] = [pair]
예제 #6
0
def convertEntities(text):
    text = text.replace("&nbsp;", " ")
    text = entities.convertEntities(text)
    return text