Ejemplo n.º 1
0
def processSimpleCategory(sectLines):
    objectOut = {}

    termDict = {
        '[notegram]': 'grammar-notes',
        '[meanings]': 'meaning',
        '[examples]': 'examples',
        '[synonyms]': 'synonyms',
        '[notebold]': 'highlight',
        '[notetone]': 'register',
        '[notearea]': 'region-domain',
        '[crossref]': 'cross-reference'
    }

    categoryKey = ''
    for line in sectLines:
        key, text = splitLine(line)
        if (key == '[category]'):
            categoryKey = text
            objectOut[categoryKey] = {'senses': [{}]}
        elif (key == '[inflects]'):
            textInflects = listToString(text)
            objectOut[categoryKey]['inflections'] = textInflects
        else:
            newKey = termDict[key]
            if (key == '[examples]'):
                newText = listToList(text)
            else:
                temp = listToString(text)
                newText = temp.replace(', ,', ',')

            objectOut[categoryKey]['senses'][0][newKey] = newText

    #pprint(objectOut)
    return objectOut
Ejemplo n.º 2
0
def processMeanings(senseLines):
    objectOut = {}
    termDict = {
        '[sensenum]': 'sense-number',
        '[notegram]': 'grammer-notes',
        '[meanings]': 'meaning',
        '[examples]': 'examples',
        '[synonyms]': 'synonyms',
        '[notebold]': 'highlight',
        '[notetone]': 'register',
        '[notearea]': 'region-domain',
        '[crossref]': 'cross-reference',
        '[variants]': 'spelling-variants'
    }

    for line in senseLines:
        #print('\n', line)
        key, text = splitLine(line)
        newKey = termDict[key]
        if (key == '[examples]'):
            newText = listToList(text)
        else:
            temp = listToString(text)
            newText = temp.replace(', ,', ',')
        objectOut[newKey] = newText

    #pprint(objectOut)
    return objectOut
Ejemplo n.º 3
0
def processSimplePhrase(lines):
    objectOut = {}

    termDict = {
        '[phrshead]': 'phrase',
        '[notegram]': 'grammar-notes',
        '[meanings]': 'meaning',
        '[examples]': 'examples',
        '[synonyms]': 'synonyms',
        '[notebold]': 'highlight',
        '[notetone]': 'register',
        '[notearea]': 'region-domain',
        '[sensenum]': 'sense-number',
        '[crossref]': 'cross-reference'
    }

    for line in lines:
        key, text = splitLine(line)
        newKey = termDict[key]
        if (key == '[examples]'):
            newText = listToList(text)
        else:
            temp = listToString(text)
            newText = temp.replace(', ,', ',')
        objectOut[newKey] = newText
    return objectOut