-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathcustom_extractor.py
41 lines (37 loc) · 1.07 KB
/
custom_extractor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from typing import Any, Optional
from neo4j_graphrag.experimental.components.entity_relation_extractor import (
EntityRelationExtractor,
OnError,
)
from neo4j_graphrag.experimental.components.types import (
DocumentInfo,
LexicalGraphConfig,
Neo4jGraph,
TextChunks,
)
class MyExtractor(EntityRelationExtractor):
def __init__(
self,
*args: Any,
on_error: OnError = OnError.IGNORE,
create_lexical_graph: bool = True,
**kwargs: Any,
) -> None:
super().__init__(
*args,
on_error=on_error,
create_lexical_graph=create_lexical_graph,
**kwargs,
)
async def run(
self,
chunks: TextChunks,
document_info: Optional[DocumentInfo] = None,
lexical_graph_config: Optional[LexicalGraphConfig] = None,
**kwargs: Any,
) -> Neo4jGraph:
# Implement your logic here
# you can loop over all text chunks with:
for chunk in chunks.chunks:
pass
return Neo4jGraph(nodes=[], relationships=[])