2020class GraphGen :
2121 unique_id : int = int (time .time ())
2222 working_dir : str = os .path .join (sys_path , "cache" )
23- full_docs_storage : JsonKVStorage = JsonKVStorage (
24- working_dir , namespace = "full_docs"
25- )
26- text_chunks_storage : JsonKVStorage = JsonKVStorage (
27- working_dir , namespace = "text_chunks"
28- )
29- wiki_storage : JsonKVStorage = JsonKVStorage (
30- working_dir , namespace = "wiki"
31- )
32- graph_storage : NetworkXStorage = NetworkXStorage (
33- working_dir , namespace = "graph"
34- )
35- rephrase_storage : JsonKVStorage = JsonKVStorage (
36- working_dir , namespace = "rephrase"
37- )
38- qa_storage : JsonKVStorage = JsonKVStorage (
39- os .path .join (working_dir , "data" , "graphgen" , str (unique_id )), namespace = f"qa-{ unique_id } "
40- )
4123
4224 # text chunking
4325 chunk_size : int = 1024
@@ -55,6 +37,26 @@ class GraphGen:
5537 # traverse strategy
5638 traverse_strategy : TraverseStrategy = TraverseStrategy ()
5739
40+ def __post_init__ (self ):
41+ self .full_docs_storage : JsonKVStorage = JsonKVStorage (
42+ self .working_dir , namespace = "full_docs"
43+ )
44+ self .text_chunks_storage : JsonKVStorage = JsonKVStorage (
45+ self .working_dir , namespace = "text_chunks"
46+ )
47+ self .wiki_storage : JsonKVStorage = JsonKVStorage (
48+ self .working_dir , namespace = "wiki"
49+ )
50+ self .graph_storage : NetworkXStorage = NetworkXStorage (
51+ self .working_dir , namespace = "graph"
52+ )
53+ self .rephrase_storage : JsonKVStorage = JsonKVStorage (
54+ self .working_dir , namespace = "rephrase"
55+ )
56+ self .qa_storage : JsonKVStorage = JsonKVStorage (
57+ os .path .join (self .working_dir , "data" , "graphgen" , str (self .unique_id )), namespace = f"qa-{ self .unique_id } "
58+ )
59+
5860 async def async_split_chunks (self , data : Union [List [list ], List [dict ]], data_type : str ) -> dict :
5961 # TODO: 是否进行指代消解
6062 if len (data ) == 0 :
0 commit comments