@@ -94,6 +94,12 @@ def parse(self) -> SimpleAnnotation:
94
94
JSONファイルをパースする。
95
95
"""
96
96
97
+ @abc .abstractmethod
98
+ def load_json (self ) -> Any :
99
+ """
100
+ JSONファイルをloadします。
101
+ """
102
+
97
103
98
104
class FullAnnotationParser (abc .ABC ):
99
105
"""
@@ -181,10 +187,11 @@ def __init__(self, zip_file: zipfile.ZipFile, json_file_path: str):
181
187
super ().__init__ (json_file_path )
182
188
183
189
def parse (self ) -> SimpleAnnotation :
190
+ return SimpleAnnotation .from_dict (self .load_json ()) # type: ignore
191
+
192
+ def load_json (self ) -> Any :
184
193
with self .__zip_file .open (self .json_file_path ) as entry :
185
- anno_dict : dict = json .load (entry )
186
- # mypyの "has no attribute "from_dict" " をignore
187
- return SimpleAnnotation .from_dict (anno_dict ) # type: ignore
194
+ return json .load (entry )
188
195
189
196
def open_outer_file (self , data_uri : str ):
190
197
outer_file_path = _trim_extension (self .json_file_path ) + "/" + data_uri
@@ -213,9 +220,11 @@ def __init__(self, json_file_path: Path):
213
220
super ().__init__ (str (json_file_path ))
214
221
215
222
def parse (self ) -> SimpleAnnotation :
223
+ return SimpleAnnotation .from_dict (self .load_json ()) # type: ignore
224
+
225
+ def load_json (self ) -> Any :
216
226
with open (self .json_file_path , encoding = "utf-8" ) as f :
217
- anno_dict : dict = json .load (f )
218
- return SimpleAnnotation .from_dict (anno_dict ) # type: ignore
227
+ return json .load (f )
219
228
220
229
def open_outer_file (self , data_uri : str ):
221
230
outer_file_path = _trim_extension (self .json_file_path ) + "/" + data_uri
0 commit comments