mflbackend/src/backend.py
def listing():
    """
    Make a short listing of possible values. Used for population dropdowns
    Possible values to list: class, wf/wordform, paradigm
    """
    q = request.args.get('q', '')  # querystring
    s = request.args.get('c', '*')  # compilation field
    lexicon = request.args.get('lexicon', C.config['default'])
    size = request.args.get('size', '100')
    lexconf = lexconfig.get_lexiconconf(lexicon)
    pos = helpers.read_pos(lexconf)
    query = []  # will contain all parts of the karp query
    # if pos tag(s) is given, filter out this/these
    if pos:
        query.append('and|%s|equals|%s' % (lexconf["pos"], '|'.join(pos)))

    if s == 'class':
        # list all inflectional classes
        classname = request.args.get('classname', '')
        query = helpers.search_q(query, classname, q, lexicon)
        res = helpers.karp_query('statlist',
                                 {'q': query,
                                  'size': size,
                                  'buckets': classname+'.bucket'},
                                 resource=lexconf['lexiconName'],
                                 mode=lexconf['lexiconMode'])
        return jsonify({"compiled_on": classname,
                        "list": res['stat_table'],
                        "fields": [classname, "entries"]})

    if s in ["wf", "wordform"]:
        # list all words
        # TODO this is probably not correct, due to ES approx
        # TODO fix bug for es6 in karp
        query = helpers.search_q(query, lexconf["baseform"], q, lexicon)
        res = helpers.karp_query('statlist',
                                 {'q': query,
                                  'size': size,
                                  'buckets': lexconf["baseform"]+'.bucket'},
                                 resource=lexconf['lexiconName'],
                                 mode=lexconf['lexiconMode'])
        return jsonify({"compiled_on": "wordform",
                        "list": res['stat_table'],
                        "fields": ["baseform", "entries"]})

    elif s == "paradigm":
        # list all (extract)paradigms
        query = helpers.search_q(query, lexconf["extractparadigm"], q, lexicon)
        res = helpers.karp_query('statlist',
                                 {'q': query,
                                  'size': size,
                                  'buckets': lexconf["extractparadigm"]+'.bucket'},
                                 resource=lexconf['lexiconName'],
                                 mode=lexconf['lexiconMode'])
        return jsonify({"compiled_on": "paradigm",
                        "list": res['stat_table'],
                        "fields": ["paradigm", "entries"]})
    else:
        raise e.MflException("Don't know what to do", code="unknown_action")

    Make a short listing of possible values. Used for population dropdowns
    Possible values to list: class, wf/wordform, paradigm
    
Make a short listing of possible values. Used for population dropdowns
Possible values to list: class, wf/wordform, paradigm
Make a short listing of possible values . Used for population dropdowns Possible values to list : class wf / wordform paradigm
def listing():
    q = request.args.get('q', '')  
    s = request.args.get('c', '*')  
    lexicon = request.args.get('lexicon', C.config['default'])
    size = request.args.get('size', '100')
    lexconf = lexconfig.get_lexiconconf(lexicon)
    pos = helpers.read_pos(lexconf)
    query = []  
    if pos:
        query.append('and|%s|equals|%s' % (lexconf["pos"], '|'.join(pos)))
    if s == 'class':
        classname = request.args.get('classname', '')
        query = helpers.search_q(query, classname, q, lexicon)
        res = helpers.karp_query('statlist',
                                 {'q': query,
                                  'size': size,
                                  'buckets': classname+'.bucket'},
                                 resource=lexconf['lexiconName'],
                                 mode=lexconf['lexiconMode'])
        return jsonify({"compiled_on": classname,
                        "list": res['stat_table'],
                        "fields": [classname, "entries"]})
    if s in ["wf", "wordform"]:
        query = helpers.search_q(query, lexconf["baseform"], q, lexicon)
        res = helpers.karp_query('statlist',
                                 {'q': query,
                                  'size': size,
                                  'buckets': lexconf["baseform"]+'.bucket'},
                                 resource=lexconf['lexiconName'],
                                 mode=lexconf['lexiconMode'])
        return jsonify({"compiled_on": "wordform",
                        "list": res['stat_table'],
                        "fields": ["baseform", "entries"]})
    elif s == "paradigm":
        query = helpers.search_q(query, lexconf["extractparadigm"], q, lexicon)
        res = helpers.karp_query('statlist',
                                 {'q': query,
                                  'size': size,
                                  'buckets': lexconf["extractparadigm"]+'.bucket'},
                                 resource=lexconf['lexiconName'],
                                 mode=lexconf['lexiconMode'])
        return jsonify({"compiled_on": "paradigm",
                        "list": res['stat_table'],
                        "fields": ["paradigm", "entries"]})
    else:
        raise e.MflException("Don't know what to do", code="unknown_action")
def listing ( ) : q = request . args . get ( 'q' , '' ) s = request . args . get ( 'c' , '*' ) lexicon = request . args . get ( 'lexicon' , C . config [ 'default' ] ) size = request . args . get ( 'size' , '100' ) lexconf = lexconfig . get_lexiconconf ( lexicon ) pos = helpers . read_pos ( lexconf ) query = [ ] if pos : query . append ( 'and|%s|equals|%s' % ( lexconf [ "pos" ] , '|' . join ( pos ) ) ) if s == 'class' : classname = request . args . get ( 'classname' , '' ) query = helpers . search_q ( query , classname , q , lexicon ) res = helpers . karp_query ( 'statlist' , { 'q' : query , 'size' : size , 'buckets' : classname + '.bucket' } , resource = lexconf [ 'lexiconName' ] , mode = lexconf [ 'lexiconMode' ] ) return jsonify ( { "compiled_on" : classname , "list" : res [ 'stat_table' ] , "fields" : [ classname , "entries" ] } ) if s in [ "wf" , "wordform" ] : query = helpers . search_q ( query , lexconf [ "baseform" ] , q , lexicon ) res = helpers . karp_query ( 'statlist' , { 'q' : query , 'size' : size , 'buckets' : lexconf [ "baseform" ] + '.bucket' } , resource = lexconf [ 'lexiconName' ] , mode = lexconf [ 'lexiconMode' ] ) return jsonify ( { "compiled_on" : "wordform" , "list" : res [ 'stat_table' ] , "fields" : [ "baseform" , "entries" ] } ) elif s == "paradigm" : query = helpers . search_q ( query , lexconf [ "extractparadigm" ] , q , lexicon ) res = helpers . karp_query ( 'statlist' , { 'q' : query , 'size' : size , 'buckets' : lexconf [ "extractparadigm" ] + '.bucket' } , resource = lexconf [ 'lexiconName' ] , mode = lexconf [ 'lexiconMode' ] ) return jsonify ( { "compiled_on" : "paradigm" , "list" : res [ 'stat_table' ] , "fields" : [ "paradigm" , "entries" ] } ) else : raise e . MflException ( "Don't know what to do" , code = "unknown_action" )
Make a short listing of possible values.
Make a short listing of possible values .
"""
    Make a short listing of possible values. Used for population dropdowns
    Possible values to list: class, wf/wordform, paradigm
    """ # querystring # compilation field # will contain all parts of the karp query # if pos tag(s) is given, filter out this/these # list all inflectional classes # list all words # TODO this is probably not correct, due to ES approx # TODO fix bug for es6 in karp # list all (extract)paradigms