graphragzen.entity_extraction.extract_entities.raw_entities_to_graph
- graphragzen.entity_extraction.extract_entities.raw_entities_to_graph(input, graph=None, raw_entities_column='raw_entities', reference_column='chunk_id', feature_delimiter='\n')[source]
Parse the result from raw entity extraction to create an undirected unipartite graph
- Parameters:
input (Union[pd.DataFrame, List[str], str]) – If a dataframe is provided it should contain a raw_entities_column column (json strings) and a reference_column (whos value will be added to the nodes and edges metadata).
graph (nx.Graph, optional) – Pre-established graph to add the extracted entities to. If not provided will create a new graph. Defaults to None.
raw_entities_column (str, optional) – Column in a DataFrame that contains the output of entity extraction. Defaults to ‘raw_entities’.
reference_column (str, optional) – Value from this column in the DataFrame will be added to the edged and nodes as ‘source_id’. This allows to reference to the source where entities were extracted from when quiring the graph. Defaults to ‘chunk_id’.
feature_delimiter (str, optional) – When the same node or edge is found multiple times, features added to the entity are concatenated using this delimiter. Defaults to ‘n’.
- Returns:
unipartite graph
- Return type:
nx.Graph