Пример #1
0
def knowledge_graph_overlay(
        obj: Query = Body(..., example=kg_overlay_example),
        reasoner: bool = False,
        conn=Depends(get_db),
) -> Message:
    """Query for knowledge graph co-occurrence overlay."""
    return_value = knowledgegraph.co_occurrence_overlay(conn, downgrade_Query(obj))

    message = dict()
    if "query_graph" in return_value:
        message["query_graph"] = upgrade_QueryGraph(return_value.pop("query_graph"))
    if "knowledge_graph" in return_value:
        message["knowledge_graph"] = upgrade_KnowledgeGraph(return_value.pop("knowledge_graph"))
    if "results" in return_value:
        message["results"] = [
            upgrade_Result(result)
            for result in return_value.pop("results")
        ]
    return_value = {
        "message": message,
        **return_value,
    }
    if reasoner:
        return return_value
    return {"return value": return_value}
Пример #2
0
def knowledge_graph_one_hop(
        obj: Query = Body(..., example=kg_onehop_example),
        reasoner: bool = False,
        conn=Depends(get_db),
) -> Message:
    """Query the ICEES clinical reasoner for knowledge graph one hop."""
    return_value = knowledgegraph.one_hop(conn, downgrade_Query(obj))

    message = dict()
    if "query_graph" in return_value:
        message["query_graph"] = upgrade_QueryGraph(return_value.pop("query_graph"))
    if "knowledge_graph" in return_value:
        message["knowledge_graph"] = upgrade_KnowledgeGraph(return_value.pop("knowledge_graph"))
    if "results" in return_value:
        message["results"] = [
            upgrade_Result(result)
            for result in return_value.pop("results")
        ]
    return_value = {
        "message": message,
        **return_value,
    }
    if reasoner:
        return return_value
    return {"return value": return_value}
Пример #3
0
def knowledge_graph(
        obj: Query = Body(..., example=knowledge_graph_example),
        reasoner: bool = False,
        conn=Depends(get_db),
) -> Message:
    """Query for knowledge graph associations between concepts."""
    return_value = knowledgegraph.get(conn, downgrade_Query(obj))

    message = dict()
    if "query_graph" in return_value:
        message["query_graph"] = upgrade_QueryGraph(return_value.pop("query_graph"))
    if "knowledge_graph" in return_value:
        message["knowledge_graph"] = upgrade_KnowledgeGraph(return_value.pop("knowledge_graph"))
    if "results" in return_value:
        message["results"] = [
            upgrade_Result(result)
            for result in return_value.pop("results")
        ]
    return_value = {
        "message": message,
        **return_value,
    }
    if reasoner:
        return return_value
    return {"return value": return_value}