mflbackend/src/helpers.py
def karp_wftableize(lexicon, paradigm, table, classes=None, baseform='',
                    identifier='', pos='', resource=''):
    """ Format a word table into a Karp friendly json object """
    def default(paradigm, table, classes, baseform, identifier, pos, resource):
        # TODO implement something more generic?
        table = table.split(',')
        obj = {'lexiconName': resource}
        wfs = []
        for l in table:
            if '|' in l:
                form, tag = l.split('|')
            else:
                form = l
                tag = ''
            wfs.append({'writtenForm': form, 'msd': tag})
            if not baseform:
                baseform = form

        obj['WordForms'] = wfs
        form = {}
        form['identifier'] = identifier
        form['partOfSpeech'] = pos
        form['baseform'] = baseform
        form['paradigm'] = paradigm
        for key, val in classes.items():
            form[key] = val
        obj['FormRepresentations'] = [form]
        obj['used_default'] = 'true'
        return obj

    func = extra_src(lexicon, 'karp_wftableize', default)

    if not classes:
        classes = {}
    return func(paradigm, table, classes, baseform, identifier, pos, resource)
 Format a word table into a Karp friendly json object 
Format a word table into a Karp friendly json object
Format a word table into a Karp friendly json object
def karp_wftableize(lexicon, paradigm, table, classes=None, baseform='',
                    identifier='', pos='', resource=''):
    def default(paradigm, table, classes, baseform, identifier, pos, resource):
        table = table.split(',')
        obj = {'lexiconName': resource}
        wfs = []
        for l in table:
            if '|' in l:
                form, tag = l.split('|')
            else:
                form = l
                tag = ''
            wfs.append({'writtenForm': form, 'msd': tag})
            if not baseform:
                baseform = form
        obj['WordForms'] = wfs
        form = {}
        form['identifier'] = identifier
        form['partOfSpeech'] = pos
        form['baseform'] = baseform
        form['paradigm'] = paradigm
        for key, val in classes.items():
            form[key] = val
        obj['FormRepresentations'] = [form]
        obj['used_default'] = 'true'
        return obj
    func = extra_src(lexicon, 'karp_wftableize', default)
    if not classes:
        classes = {}
    return func(paradigm, table, classes, baseform, identifier, pos, resource)
def karp_wftableize ( lexicon , paradigm , table , classes = None , baseform = '' , identifier = '' , pos = '' , resource = '' ) : def default ( paradigm , table , classes , baseform , identifier , pos , resource ) : table = table . split ( ',' ) obj = { 'lexiconName' : resource } wfs = [ ] for l in table : if '|' in l : form , tag = l . split ( '|' ) else : form = l tag = '' wfs . append ( { 'writtenForm' : form , 'msd' : tag } ) if not baseform : baseform = form obj [ 'WordForms' ] = wfs form = { } form [ 'identifier' ] = identifier form [ 'partOfSpeech' ] = pos form [ 'baseform' ] = baseform form [ 'paradigm' ] = paradigm for key , val in classes . items ( ) : form [ key ] = val obj [ 'FormRepresentations' ] = [ form ] obj [ 'used_default' ] = 'true' return obj func = extra_src ( lexicon , 'karp_wftableize' , default ) if not classes : classes = { } return func ( paradigm , table , classes , baseform , identifier , pos , resource )
Format a word table into a Karp friendly json object
Format a word table into a Karp friendly json object
""" Format a word table into a Karp friendly json object """ # TODO implement something more generic?
lexicon
paradigm
table
classes
baseform
identifier
pos
resource