示例#1
0
def build_parser(options):
    parser_option = options.parser if len(PARSERS) > 1 else "camxes-ilmen"
    if parser_option == 'camxes-ilmen':
        from camxes_py.parsers import camxes_ilmen
        return camxes_ilmen.Parser(options.rule)
    else:
        bad_parser()
示例#2
0
def process_input(input_json):
    input_specs = input_json["specs"]
    parser = camxes_ilmen.Parser()
    transformer = node_coverage.Transformer(parser)
    for spec in input_specs:
        if spec["out"] != "ERROR":
            parsed = parser.parse(spec["txt"])
            transformer.visit(parsed)
    return transformer.visits()
示例#3
0
def process_input(input_json):
    input_specs = input_json["specs"]
    parser = camxes_ilmen.Parser()
    json_transformer = camxes_json.Transformer()
    morph_transformer = camxes_morphology.Transformer()
    return [
        process_spec(spec, parser, json_transformer, morph_transformer) \
            for spec in input_specs
    ]
示例#4
0
#-*- coding:utf-8 -*-

from flask import Flask, request, redirect, url_for, jsonify, render_template
import camxes_py
from camxes_py.transformers import minimal
from camxes_py.parsers import camxes_ilmen

app = Flask(__name__)

import logging
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)
app.logger.addHandler(stream_handler)

parser = camxes_ilmen.Parser(None)

if __name__ == '__main__':
    app.run(debug=True)


@app.route('/')
def index():
    text = request.args.get('text', "coi pilno mi'e camxes")

    try:
        minimal_transformer = minimal.Transformer()
        ast, node = camxes_py.match(text, parser, None, minimal_transformer,
                                    True)
        if ast is None:
            grammatical = False
示例#5
0
 def __init__(self, client):
     super(Dispatcher, self).__init__(client)
     self.parser = camxes_ilmen.Parser('vlatai')
     self.transformer = vlatai.Transformer()