mflbackend/src/backend.py
def inflectlike():
    " Inflect a word similarly to another word "
    lexicon = request.args.get('lexicon', C.config['default'])
    lexconf = lexconfig.get_lexiconconf(lexicon)
    # the word to inflect
    word = request.args.get('wordform', '')
    pos = helpers.read_one_pos(lexconf)
    # the word (or word form) with known inflection
    like = request.args.get('like')
    logging.debug('like %s', like)
    # ppriorv: setting for pextract
    ppriorv = float(request.args.get('pprior', lexconf["pprior"]))
    if not pos:
        pos = helpers.identifier2pos(lexicon, like)
    lemgram = helpers.make_identifier(lexicon, word, pos)
    # ask karp to filter out the paradigm's ID
    q = 'extended||and|%s.search|equals|%s' % ('first-attest', like)
    res = helpers.karp_query('statlist',
                             {'q': q,
                              'mode': lexconf['paradigmMode'],
                              'resource': lexconf['paradigmlexiconName'],
                              'buckets': '_id'
                             }
                            )
    # get the internal objects for these paradigms
    possible_p = [line[0] for line in res['stat_table']]
    if possible_p:
        paras, numex, lms = helpers.relevant_paradigms(paradigmdict, lexicon,
                                                       pos,
                                                       possible_p=possible_p)

        logging.debug('test %s paradigms', len(paras))
        # is the given form necessarily the baseform?
        restrict_to_baseform = helpers.read_restriction(lexconf)
        res = mp.run_paradigms(paras, [word], kbest=100, pprior=ppriorv,
                               lms=lms, numexamples=numex, vbest=20,
                               baseform=restrict_to_baseform)
        result = helpers.format_kbest(lexicon, res, pos=pos, lemgram=lemgram)
    else:
        # the wordform could not be inflected like the given word
        result = []
    return jsonify({"Results": result})
 Inflect a word similarly to another word 
Inflect a word similarly to another word
Inflect a word similarly to another word
def inflectlike():
    lexicon = request.args.get('lexicon', C.config['default'])
    lexconf = lexconfig.get_lexiconconf(lexicon)
    word = request.args.get('wordform', '')
    pos = helpers.read_one_pos(lexconf)
    like = request.args.get('like')
    logging.debug('like %s', like)
    ppriorv = float(request.args.get('pprior', lexconf["pprior"]))
    if not pos:
        pos = helpers.identifier2pos(lexicon, like)
    lemgram = helpers.make_identifier(lexicon, word, pos)
    q = 'extended||and|%s.search|equals|%s' % ('first-attest', like)
    res = helpers.karp_query('statlist',
                             {'q': q,
                              'mode': lexconf['paradigmMode'],
                              'resource': lexconf['paradigmlexiconName'],
                              'buckets': '_id'
                             }
                            )
    possible_p = [line[0] for line in res['stat_table']]
    if possible_p:
        paras, numex, lms = helpers.relevant_paradigms(paradigmdict, lexicon,
                                                       pos,
                                                       possible_p=possible_p)
        logging.debug('test %s paradigms', len(paras))
        restrict_to_baseform = helpers.read_restriction(lexconf)
        res = mp.run_paradigms(paras, [word], kbest=100, pprior=ppriorv,
                               lms=lms, numexamples=numex, vbest=20,
                               baseform=restrict_to_baseform)
        result = helpers.format_kbest(lexicon, res, pos=pos, lemgram=lemgram)
    else:
        result = []
    return jsonify({"Results": result})
def inflectlike ( ) : lexicon = request . args . get ( 'lexicon' , C . config [ 'default' ] ) lexconf = lexconfig . get_lexiconconf ( lexicon ) word = request . args . get ( 'wordform' , '' ) pos = helpers . read_one_pos ( lexconf ) like = request . args . get ( 'like' ) logging . debug ( 'like %s' , like ) ppriorv = float ( request . args . get ( 'pprior' , lexconf [ "pprior" ] ) ) if not pos : pos = helpers . identifier2pos ( lexicon , like ) lemgram = helpers . make_identifier ( lexicon , word , pos ) q = 'extended||and|%s.search|equals|%s' % ( 'first-attest' , like ) res = helpers . karp_query ( 'statlist' , { 'q' : q , 'mode' : lexconf [ 'paradigmMode' ] , 'resource' : lexconf [ 'paradigmlexiconName' ] , 'buckets' : '_id' } ) possible_p = [ line [ 0 ] for line in res [ 'stat_table' ] ] if possible_p : paras , numex , lms = helpers . relevant_paradigms ( paradigmdict , lexicon , pos , possible_p = possible_p ) logging . debug ( 'test %s paradigms' , len ( paras ) ) restrict_to_baseform = helpers . read_restriction ( lexconf ) res = mp . run_paradigms ( paras , [ word ] , kbest = 100 , pprior = ppriorv , lms = lms , numexamples = numex , vbest = 20 , baseform = restrict_to_baseform ) result = helpers . format_kbest ( lexicon , res , pos = pos , lemgram = lemgram ) else : result = [ ] return jsonify ( { "Results" : result } )
Inflect a word similarly to another word
Inflect a word similarly to another word
" Inflect a word similarly to another word " # the word to inflect # the word (or word form) with known inflection # ppriorv: setting for pextract # ask karp to filter out the paradigm's ID # get the internal objects for these paradigms # is the given form necessarily the baseform? # the wordform could not be inflected like the given word