Ejemplo n.º 1
0
def get_generic_expression(expression: nlpql_parserParser.ExpressionContext, entities: list(), operator: list()):
    txt = expression.getText()
    if expression.getChildCount() == 1:
        child = expression.getChild(0)
        if type(child) == nlpql_parserParser.LogicalOperatorContext:
            operator.append(txt)
        else:
            entities.append(txt)
    else:
        for exp in expression.getChildren():
            txt = exp.getText()
            if type(exp) == nlpql_parserParser.LogicalOperatorContext:
                operator.append(txt)
            else:
                get_generic_expression(exp, entities, operator)

    return entities, operator
Ejemplo n.º 2
0
def get_generic_expression(expression: nlpql_parserParser.ExpressionContext, entities: list(), operator: list()):
    txt = expression.getText()
    if expression.getChildCount() == 1:
        child = expression.getChild(0)
        if type(child) == nlpql_parserParser.LogicalOperatorContext:
            operator.append(txt)
        else:
            entities.append(txt)
    else:
        for exp in expression.getChildren():
            txt = exp.getText()
            if type(exp) == nlpql_parserParser.LogicalOperatorContext:
                operator.append(txt)
            else:
                get_generic_expression(exp, entities, operator)

    return entities, operator
Ejemplo n.º 3
0
def get_logical_expression(expression: nlpql_parserParser.ExpressionContext,
                           define_name, final):
    print(expression)
    entities = list()
    operator = list()

    for c in expression.getChildren():
        if type(c) == nlpql_parserParser.ExpressionContext:
            get_generic_expression(c, entities, operator)

        elif type(c) == nlpql_parserParser.LogicalOperatorContext:
            operator.append(c.getText())

    op = PhenotypeOperations(define_name,
                             operator[0],
                             entities,
                             final=final,
                             raw_text=expression.getText())
    return op
Ejemplo n.º 4
0
def get_not_expression(expression: nlpql_parserParser.ExpressionContext,
                       define_name, final):
    print(expression)
    entities = list()
    operator = ""

    op = PhenotypeOperations(define_name,
                             operator,
                             entities,
                             final=final,
                             raw_text=expression.getText())
    return op
Ejemplo n.º 5
0
def get_logical_expression(expression: nlpql_parserParser.ExpressionContext, define_name, final):
    print(expression)
    entities = list()
    operator = list()

    for c in expression.getChildren():
        if type(c) == nlpql_parserParser.ExpressionContext:
            get_generic_expression(c, entities, operator)

        elif type(c) == nlpql_parserParser.LogicalOperatorContext:
            operator.append(c.getText())

    op = PhenotypeOperations(define_name, operator[0], entities, final=final, raw_text=get_pretty_text(expression))
    return op