mflbackend/src/helpers.py
def relevant_paradigms(paradigmdict, lexicon, pos, possible_p=[]):
    """ Returns a subset of the paradigms.
    Args:
        paradigmdict (dict): a dictionary with all paradigms
            '{"lexname": {"nn": [], "vb": []}'
        lexicon (str): the lexicon name
        pos (str): the tables word class
        possible_p (list, optional): a list of all acceptable paradigm id:s.
           If left empty, all paradigms are considered ok.
    Returns:
        (a list of paradigm object (obj),
         number of examples (float),
         alphabet/language model (set))
    Raises:
        MflException if the lexicon name could not be found
    """
    try:
        all_paras, numex, lms, alpha = paradigmdict[lexicon].get(pos, ({}, 0, None, ''))
        if possible_p:
            # print('search for %s (%s)' % (possible_p[0], all_paras))
            all_paras = [all_paras[p] for p in possible_p if p in all_paras]
        else:
            all_paras = list(all_paras.values())

        return all_paras, numex, lms
    except:
        raise errs.MflException("Could not read lexicon %s" % lexicon,
                                code="unknown_lexicon")
 Returns a subset of the paradigms.
    Args:
        paradigmdict (dict): a dictionary with all paradigms
            '{"lexname": {"nn": [], "vb": []}'
        lexicon (str): the lexicon name
        pos (str): the tables word class
        possible_p (list, optional): a list of all acceptable paradigm id:s.
           If left empty, all paradigms are considered ok.
    Returns:
        (a list of paradigm object (obj),
         number of examples (float),
         alphabet/language model (set))
    Raises:
        MflException if the lexicon name could not be found
    
Returns a subset of the paradigms.
Returns a subset of the paradigms .
def relevant_paradigms(paradigmdict, lexicon, pos, possible_p=[]):
    try:
        all_paras, numex, lms, alpha = paradigmdict[lexicon].get(pos, ({}, 0, None, ''))
        if possible_p:
            all_paras = [all_paras[p] for p in possible_p if p in all_paras]
        else:
            all_paras = list(all_paras.values())
        return all_paras, numex, lms
    except:
        raise errs.MflException("Could not read lexicon %s" % lexicon,
                                code="unknown_lexicon")
def relevant_paradigms ( paradigmdict , lexicon , pos , possible_p = [ ] ) : try : all_paras , numex , lms , alpha = paradigmdict [ lexicon ] . get ( pos , ( { } , 0 , None , '' ) ) if possible_p : all_paras = [ all_paras [ p ] for p in possible_p if p in all_paras ] else : all_paras = list ( all_paras . values ( ) ) return all_paras , numex , lms except : raise errs . MflException ( "Could not read lexicon %s" % lexicon , code = "unknown_lexicon" )
Returns a subset of the paradigms.
Returns a subset of the paradigms .
""" Returns a subset of the paradigms.
    Args:
        paradigmdict (dict): a dictionary with all paradigms
            '{"lexname": {"nn": [], "vb": []}'
        lexicon (str): the lexicon name
        pos (str): the tables word class
        possible_p (list, optional): a list of all acceptable paradigm id:s.
           If left empty, all paradigms are considered ok.
    Returns:
        (a list of paradigm object (obj),
         number of examples (float),
         alphabet/language model (set))
    Raises:
        MflException if the lexicon name could not be found
    """ # print('search for %s (%s)' % (possible_p[0], all_paras))
paradigmdict
lexicon
pos
possible_p