mflbackend/src/helpers.py
def karp_tableize(lexicon, table, paradigm=None, pos='', identifier='', score=0):
    " Format a generated inflection table into a Karp friendly json object "
    table = table.split(',')
    obj = {'score': score, 'paradigm': '', 'new': True}
    if paradigm is not None:
        obj['variables'] = dict([var for var in paradigm.var_insts[0][1:]])
        obj['paradigm'] = paradigm.name
        obj['pattern'] = paradigm.jsonify()
    wfs = []
    for l in table:
        if '|' in l:
            form, tag = l.split('|')
        else:
            form = l
            tag = 'X'
        wfs.append({'writtenForm': form, 'msd': tag})

    obj['WordForms'] = wfs
    func = extra_src(lexicon, 'get_baseform', '')
    obj['baseform'] = func(obj)
    obj['partOfSpeech'] = pos
    obj['paradigm_entries'] = 0
    obj['identifier'] = identifier
    return show_inflected(lexicon, obj)
 Format a generated inflection table into a Karp friendly json object 
Format a generated inflection table into a Karp friendly json object
Format a generated inflection table into a Karp friendly json object
def karp_tableize(lexicon, table, paradigm=None, pos='', identifier='', score=0):
    table = table.split(',')
    obj = {'score': score, 'paradigm': '', 'new': True}
    if paradigm is not None:
        obj['variables'] = dict([var for var in paradigm.var_insts[0][1:]])
        obj['paradigm'] = paradigm.name
        obj['pattern'] = paradigm.jsonify()
    wfs = []
    for l in table:
        if '|' in l:
            form, tag = l.split('|')
        else:
            form = l
            tag = 'X'
        wfs.append({'writtenForm': form, 'msd': tag})
    obj['WordForms'] = wfs
    func = extra_src(lexicon, 'get_baseform', '')
    obj['baseform'] = func(obj)
    obj['partOfSpeech'] = pos
    obj['paradigm_entries'] = 0
    obj['identifier'] = identifier
    return show_inflected(lexicon, obj)
def karp_tableize ( lexicon , table , paradigm = None , pos = '' , identifier = '' , score = 0 ) : table = table . split ( ',' ) obj = { 'score' : score , 'paradigm' : '' , 'new' : True } if paradigm is not None : obj [ 'variables' ] = dict ( [ var for var in paradigm . var_insts [ 0 ] [ 1 : ] ] ) obj [ 'paradigm' ] = paradigm . name obj [ 'pattern' ] = paradigm . jsonify ( ) wfs = [ ] for l in table : if '|' in l : form , tag = l . split ( '|' ) else : form = l tag = 'X' wfs . append ( { 'writtenForm' : form , 'msd' : tag } ) obj [ 'WordForms' ] = wfs func = extra_src ( lexicon , 'get_baseform' , '' ) obj [ 'baseform' ] = func ( obj ) obj [ 'partOfSpeech' ] = pos obj [ 'paradigm_entries' ] = 0 obj [ 'identifier' ] = identifier return show_inflected ( lexicon , obj )
Format a generated inflection table into a Karp friendly json object
Format a generated inflection table into a Karp friendly json object
" Format a generated inflection table into a Karp friendly json object "
lexicon
table
paradigm
pos
identifier
score