langchain_community.chains.graph_qa.cypher_utils
.CypherQueryCorrector¶
- class langchain_community.chains.graph_qa.cypher_utils.CypherQueryCorrector(schemas: List[Schema])[source]¶
用于在生成的Cypher语句中纠正关系方向。 这段代码是从Cypher比赛的获奖者提交中复制的: https://github.com/sakusaku-rich/cypher-direction-competition
参数: schemas: schema的列表
Attributes
node_pattern
node_relation_node_pattern
path_pattern
property_pattern
relation_type_pattern
Methods
__init__
(schemas)参数: schemas: schema的列表
clean_node
(node)参数: node:以字符串格式表示的节点
correct_query
(query)参数: query: Cypher查询语句
detect_labels
(str_node, node_variable_dict)参数: str_node:以字符串格式表示的节点 node_variable_dict:节点变量的字典
detect_node_variables
(query)参数: query: Cypher查询语句
detect_relation_types
(str_relation)参数: str_relation: 字符串格式的关系
extract_node_variable
(part)参数: part:字符串格式中的节点
extract_paths
(query)参数: query: Cypher查询语句
judge_direction
(relation)参数: relation: 字符串格式的关系
verify_schema
(from_node_labels, ...)参数: from_node_labels:起始节点的标签 relation_type:关系的类型 to_node_labels:目标节点的标签
- Parameters
schemas (List[Schema]) –
- correct_query(query: str) str [source]¶
参数: query: Cypher查询语句
- Parameters
query (str) –
- Return type
str
- detect_labels(str_node: str, node_variable_dict: Dict[str, Any]) List[str] [source]¶
参数: str_node:以字符串格式表示的节点 node_variable_dict:节点变量的字典
- Parameters
str_node (str) –
node_variable_dict (Dict[str, Any]) –
- Return type
List[str]
- detect_node_variables(query: str) Dict[str, List[str]] [source]¶
参数: query: Cypher查询语句
- Parameters
query (str) –
- Return type
Dict[str, List[str]]
- detect_relation_types(str_relation: str) Tuple[str, List[str]] [source]¶
参数: str_relation: 字符串格式的关系
- Parameters
str_relation (str) –
- Return type
Tuple[str, List[str]]
- extract_node_variable(part: str) Optional[str] [source]¶
参数: part:字符串格式中的节点
- Parameters
part (str) –
- Return type
Optional[str]
- extract_paths(query: str) List[str] [source]¶
参数: query: Cypher查询语句
- Parameters
query (str) –
- Return type
List[str]
- judge_direction(relation: str) str [source]¶
参数: relation: 字符串格式的关系
- Parameters
relation (str) –
- Return type
str
- verify_schema(from_node_labels: List[str], relation_types: List[str], to_node_labels: List[str]) bool [source]¶
参数: from_node_labels:起始节点的标签 relation_type:关系的类型 to_node_labels:目标节点的标签
- Parameters
from_node_labels (List[str]) –
relation_types (List[str]) –
to_node_labels (List[str]) –
- Return type
bool