mflbackend/src/handleparadigms.py
def add_word_to_paradigm(lexicon, paradigm, paradigms, identifier, pos,
                         classes, inst):
    """
    Add a word to extisting paradigm (update language model, save to karp)
    Args:
        lexicon (str): the lexicon name
        paradigm (obj): the paradigm (Paradigm.py)
        paradigms (dict): a dictionary with all paradigms
            '{"lexname": {"nn": [], "vb": []}'
        identifier (str): the tables identifier
        pos (str): the tables word class
        classes (dict): all inflectional classes to add '{"bklass": [3,4]}'
        inst (list): this table's variable instantiations for the paradigm
    """
    presource = lexconfig.get_paradigmlexicon(lexicon)
    lresource = lexconfig.get_lexiconname(lexicon)
    logging.debug('old count %s', paradigm.count)
    # Set variabel instannces, count, resource etc for the paradigm object
    var_inst = [('first-attest', identifier)]+list(enumerate(inst, 1))
    paradigm.add_var_insts(var_inst)
    paradigm.members.append(identifier)
    for key, val in classes.items():
        paradigm.add_class(key, [val])
    paradigm.count += 1
    paradigm.set_lexicon(presource)

    # Update our in memory paradigms and update language model
    all_paras, numex, lms, alpha = paradigms[lresource].get(pos, ({}, 0, None))
    alpha = mp.extend_alphabet(paradigm, alpha)
    paradigms[lresource][pos] = (all_paras, numex, lms, alpha)
    logging.debug('new count %s', paradigm.count)

    # Save to karp
    helpers.karp_update(paradigm.uuid, paradigm.jsonify(), resource=presource)

    Add a word to extisting paradigm (update language model, save to karp)
    Args:
        lexicon (str): the lexicon name
        paradigm (obj): the paradigm (Paradigm.py)
        paradigms (dict): a dictionary with all paradigms
            '{"lexname": {"nn": [], "vb": []}'
        identifier (str): the tables identifier
        pos (str): the tables word class
        classes (dict): all inflectional classes to add '{"bklass": [3,4]}'
        inst (list): this table's variable instantiations for the paradigm
    
Add a word to extisting paradigm (update language model, save to karp)
Add a word to extisting paradigm ( update language model save to karp )
def add_word_to_paradigm(lexicon, paradigm, paradigms, identifier, pos,
                         classes, inst):
    presource = lexconfig.get_paradigmlexicon(lexicon)
    lresource = lexconfig.get_lexiconname(lexicon)
    logging.debug('old count %s', paradigm.count)
    var_inst = [('first-attest', identifier)]+list(enumerate(inst, 1))
    paradigm.add_var_insts(var_inst)
    paradigm.members.append(identifier)
    for key, val in classes.items():
        paradigm.add_class(key, [val])
    paradigm.count += 1
    paradigm.set_lexicon(presource)
    all_paras, numex, lms, alpha = paradigms[lresource].get(pos, ({}, 0, None))
    alpha = mp.extend_alphabet(paradigm, alpha)
    paradigms[lresource][pos] = (all_paras, numex, lms, alpha)
    logging.debug('new count %s', paradigm.count)
    helpers.karp_update(paradigm.uuid, paradigm.jsonify(), resource=presource)
def add_word_to_paradigm ( lexicon , paradigm , paradigms , identifier , pos , classes , inst ) : presource = lexconfig . get_paradigmlexicon ( lexicon ) lresource = lexconfig . get_lexiconname ( lexicon ) logging . debug ( 'old count %s' , paradigm . count ) var_inst = [ ( 'first-attest' , identifier ) ] + list ( enumerate ( inst , 1 ) ) paradigm . add_var_insts ( var_inst ) paradigm . members . append ( identifier ) for key , val in classes . items ( ) : paradigm . add_class ( key , [ val ] ) paradigm . count += 1 paradigm . set_lexicon ( presource ) all_paras , numex , lms , alpha = paradigms [ lresource ] . get ( pos , ( { } , 0 , None ) ) alpha = mp . extend_alphabet ( paradigm , alpha ) paradigms [ lresource ] [ pos ] = ( all_paras , numex , lms , alpha ) logging . debug ( 'new count %s' , paradigm . count ) helpers . karp_update ( paradigm . uuid , paradigm . jsonify ( ) , resource = presource )
Add a word to extisting paradigm (update language model, save to karp)
Add a word to extisting paradigm ( update language model save to karp )
"""
    Add a word to extisting paradigm (update language model, save to karp)
    Args:
        lexicon (str): the lexicon name
        paradigm (obj): the paradigm (Paradigm.py)
        paradigms (dict): a dictionary with all paradigms
            '{"lexname": {"nn": [], "vb": []}'
        identifier (str): the tables identifier
        pos (str): the tables word class
        classes (dict): all inflectional classes to add '{"bklass": [3,4]}'
        inst (list): this table's variable instantiations for the paradigm
    """ # Set variabel instannces, count, resource etc for the paradigm object # Update our in memory paradigms and update language model # Save to karp
lexicon
the lexicon name
the lexicon name
paradigm
the paradigm (Paradigm.py)
the paradigm ( Paradigm . py )
paradigms
a dictionary with all paradigms
'{"lexname": {"nn": [], "vb": []}'
a dictionary with all paradigms ' { " lexname " : { " nn " : [] " vb " : [] } '
identifier
the tables identifier
the tables identifier
pos
the tables word class
the tables word class
classes
all inflectional classes to add '{"bklass": [3,4]}'
all inflectional classes to add ' { " bklass " : [ 3 4 ] } '
inst
this table's variable instantiations for the paradigm
this table ' s variable instantiations for the paradigm