Cypher查询校正器#
- class langchain_community.chains.graph_qa.cypher_utils.CypherQueryCorrector(schemas: List[Schema])[source]#
自版本0.3.8起已弃用:请改用
:class:`~langchain_neo4j.chains.graph_qa.cypher_utils.CypherQueryCorrector`。在langchain-community==1.0之前不会移除。用于在生成的Cypher语句中纠正关系方向。 此代码是从Cypher竞赛获胜者的提交中复制的: sakusaku-rich/cypher-direction-competition
- Parameters:
schemas (List[Schema]) – 模式列表
属性
node_patternnode_relation_node_patternpath_patternproperty_patternrelation_type_pattern方法
__init__(schemas)clean_node(node)correct_query(query)detect_labels(str_node, node_variable_dict)detect_node_variables(query)detect_relation_types(str_relation)extract_node_variable(part)extract_paths(query)judge_direction(relation)verify_schema(from_node_labels, ...)- detect_labels(str_node: str, node_variable_dict: Dict[str, Any]) List[str][source]#
- Parameters:
str_node (str) – 字符串格式的节点
node_variable_dict (Dict[str, Any]) – 节点变量的字典
- Return type:
列表[str]
- detect_node_variables(query: str) Dict[str, List[str]][source]#
- Parameters:
query (str) – cypher查询
- Return type:
Dict[str, List[str]]
- detect_relation_types(str_relation: str) Tuple[str, List[str]][source]#
- Parameters:
str_relation (str) – 字符串格式的关系
- Return type:
元组[str, 列表[str]]
- extract_node_variable(part: str) str | None[source]#
- Parameters:
部分 (str) – 字符串格式的节点
- Return type:
字符串 | 无
使用 CypherQueryCorrector 的示例