mflbackend/src/handleparadigms.py
def add_paradigm(lexicon, pid, paradigm, paradigms, identifier, pos, classes):
    """
    Add a new paradigm (update language model, save to karp).
    Args:
        lexicon (str): the lexicon name
        pid (string): the paradigms name (human readable id)
        paradigm (obj): the paradigm (Paradigm.py)
        paradigms (list): a list of all internal paradigms
        identifier (str): the tables identifier
        pos (str): the tables word class
        classes (dict): inflectional classes to add '{"bklass": [3,4]}'
    """
    presource = lexconfig.get_paradigmlexicon(lexicon)
    lresource = lexconfig.get_lexiconname(lexicon)
    logging.debug('id %s, para %s.\n classes %s, identifier %s',
                  pid, paradigm, classes, identifier)
    # Set name, id etc for the paradigm object
    paradigm.set_id(pid)
    puuid = str(uuid.uuid1())  # generate a uid and set it
    paradigm.set_uuid(puuid)
    paradigm.set_lexicon(presource)
    paradigm.set_pos(pos)
    paradigm._entries = 1
    for key, val in classes.items():
        paradigm.add_class(key, [val])
    logging.debug('uuid %s', puuid)

    # Add to our in memory paradigms and update language model
    if lresource not in paradigms:
        paradigms[lresource] = {}
    if pos not in paradigms[lresource]:
        paradigms[lresource][pos] = {}
    all_paras, numex, lms, alpha = paradigms[lresource].get(pos, ({}, 0, None))
    alpha = mp.extend_alphabet(paradigm, alpha)
    mp.lms_paradigm(paradigm, lms, alpha, lexconfig.get_ngramorder(lexicon),
                    lexconfig.get_ngramprior(lexicon))
    all_paras[puuid] = paradigm
    paradigms[lresource][pos] = (all_paras, numex+1, lms, alpha)

    # Save to karp
    helpers.karp_add(paradigm.jsonify(), resource=presource, _id=puuid)

    Add a new paradigm (update language model, save to karp).
    Args:
        lexicon (str): the lexicon name
        pid (string): the paradigms name (human readable id)
        paradigm (obj): the paradigm (Paradigm.py)
        paradigms (list): a list of all internal paradigms
        identifier (str): the tables identifier
        pos (str): the tables word class
        classes (dict): inflectional classes to add '{"bklass": [3,4]}'
    
Add a new paradigm (update language model, save to karp).
Add a new paradigm ( update language model save to karp ) .
def add_paradigm(lexicon, pid, paradigm, paradigms, identifier, pos, classes):
    presource = lexconfig.get_paradigmlexicon(lexicon)
    lresource = lexconfig.get_lexiconname(lexicon)
    logging.debug('id %s, para %s.\n classes %s, identifier %s',
                  pid, paradigm, classes, identifier)
    paradigm.set_id(pid)
    puuid = str(uuid.uuid1())  
    paradigm.set_uuid(puuid)
    paradigm.set_lexicon(presource)
    paradigm.set_pos(pos)
    paradigm._entries = 1
    for key, val in classes.items():
        paradigm.add_class(key, [val])
    logging.debug('uuid %s', puuid)
    if lresource not in paradigms:
        paradigms[lresource] = {}
    if pos not in paradigms[lresource]:
        paradigms[lresource][pos] = {}
    all_paras, numex, lms, alpha = paradigms[lresource].get(pos, ({}, 0, None))
    alpha = mp.extend_alphabet(paradigm, alpha)
    mp.lms_paradigm(paradigm, lms, alpha, lexconfig.get_ngramorder(lexicon),
                    lexconfig.get_ngramprior(lexicon))
    all_paras[puuid] = paradigm
    paradigms[lresource][pos] = (all_paras, numex+1, lms, alpha)
    helpers.karp_add(paradigm.jsonify(), resource=presource, _id=puuid)
def add_paradigm ( lexicon , pid , paradigm , paradigms , identifier , pos , classes ) : presource = lexconfig . get_paradigmlexicon ( lexicon ) lresource = lexconfig . get_lexiconname ( lexicon ) logging . debug ( 'id %s, para %s.\n classes %s, identifier %s' , pid , paradigm , classes , identifier ) paradigm . set_id ( pid ) puuid = str ( uuid . uuid1 ( ) ) paradigm . set_uuid ( puuid ) paradigm . set_lexicon ( presource ) paradigm . set_pos ( pos ) paradigm . _entries = 1 for key , val in classes . items ( ) : paradigm . add_class ( key , [ val ] ) logging . debug ( 'uuid %s' , puuid ) if lresource not in paradigms : paradigms [ lresource ] = { } if pos not in paradigms [ lresource ] : paradigms [ lresource ] [ pos ] = { } all_paras , numex , lms , alpha = paradigms [ lresource ] . get ( pos , ( { } , 0 , None ) ) alpha = mp . extend_alphabet ( paradigm , alpha ) mp . lms_paradigm ( paradigm , lms , alpha , lexconfig . get_ngramorder ( lexicon ) , lexconfig . get_ngramprior ( lexicon ) ) all_paras [ puuid ] = paradigm paradigms [ lresource ] [ pos ] = ( all_paras , numex + 1 , lms , alpha ) helpers . karp_add ( paradigm . jsonify ( ) , resource = presource , _id = puuid )
Add a new paradigm (update language model, save to karp).
Add a new paradigm ( update language model save to karp ) .
"""
    Add a new paradigm (update language model, save to karp).
    Args:
        lexicon (str): the lexicon name
        pid (string): the paradigms name (human readable id)
        paradigm (obj): the paradigm (Paradigm.py)
        paradigms (list): a list of all internal paradigms
        identifier (str): the tables identifier
        pos (str): the tables word class
        classes (dict): inflectional classes to add '{"bklass": [3,4]}'
    """ # Set name, id etc for the paradigm object # generate a uid and set it # Add to our in memory paradigms and update language model # Save to karp
lexicon
the lexicon name
the lexicon name
pid
the paradigms name (human readable id)
the paradigms name ( human readable id )
paradigm
the paradigm (Paradigm.py)
the paradigm ( Paradigm . py )
paradigms
a list of all internal paradigms
a list of all internal paradigms
identifier
the tables identifier
the tables identifier
pos
the tables word class
the tables word class
classes
inflectional classes to add '{"bklass": [3,4]}'
inflectional classes to add ' { " bklass " : [ 3 4 ] } '