|
9 | 9 | import re |
10 | 10 | from typing import Any, List |
11 | 11 |
|
12 | | -import ontospy |
13 | | - |
14 | 12 | from ...base import BaseOntologyParser, OMDataset |
| 13 | +from ..generic import GenericOntology |
15 | 14 |
|
16 | 15 | track = "mse" |
17 | 16 |
|
@@ -120,137 +119,14 @@ def get_synonyms(self, owl_class: Any) -> List: |
120 | 119 | return [] |
121 | 120 |
|
122 | 121 |
|
123 | | -class MaterialInformationOntoOntology(BaseOntologyParser): |
| 122 | +class MaterialInformationOntoOntology(GenericOntology): |
124 | 123 | """ |
125 | 124 | A parser for the Material Information Ontology. |
126 | 125 |
|
127 | 126 | This class provides methods for handling ontology items such as labels, names, IRIs, |
128 | 127 | parents, children, and more. It also provides functionality to load the ontology from a file. |
129 | 128 | """ |
130 | | - def is_contain_label(self, owl_class: Any) -> bool: |
131 | | - """ |
132 | | - Checks if the ontology class has a label. |
133 | | -
|
134 | | - Parameters: |
135 | | - owl_class (Any): The ontology class whose label presence is to be checked. |
136 | | -
|
137 | | - Returns: |
138 | | - bool: Always returns True as all classes are assumed to have labels. |
139 | | - """ |
140 | | - return True |
141 | | - |
142 | | - def get_name(self, owl_class: Any) -> str: |
143 | | - """ |
144 | | - Retrieves the name of the ontology class. |
145 | | -
|
146 | | - Parameters: |
147 | | - owl_class (Any): The ontology class whose name is to be retrieved. |
148 | | -
|
149 | | - Returns: |
150 | | - str: The name of the ontology class. |
151 | | - """ |
152 | | - return str(owl_class.uri).split("#")[1] |
153 | | - |
154 | | - def get_label(self, owl_class: Any) -> str: |
155 | | - """ |
156 | | - Retrieves and formats the label of the ontology class. |
157 | | -
|
158 | | - Parameters: |
159 | | - owl_class (Any): The ontology class whose label is to be retrieved. |
160 | | -
|
161 | | - Returns: |
162 | | - str: The formatted label of the ontology class. |
163 | | - """ |
164 | | - preprocessed_str = ( |
165 | | - self.get_iri(owl_class).split("#")[1].replace("_", " ").replace("-", "") |
166 | | - ) |
167 | | - return split_string(preprocessed_str) |
168 | | - |
169 | | - def get_iri(self, owl_class: Any) -> str: |
170 | | - """ |
171 | | - Retrieves the IRI of the ontology class. |
172 | | -
|
173 | | - Parameters: |
174 | | - owl_class (Any): The ontology class whose IRI is to be retrieved. |
175 | | -
|
176 | | - Returns: |
177 | | - str: The IRI of the ontology class. |
178 | | - """ |
179 | | - return str(owl_class.uri) |
180 | | - |
181 | | - def get_childrens(self, owl_class: Any) -> List: |
182 | | - """ |
183 | | - Retrieves the children of the ontology class. |
184 | | -
|
185 | | - Parameters: |
186 | | - owl_class (Any): The ontology class whose children are to be retrieved. |
187 | | -
|
188 | | - Returns: |
189 | | - List: A list of child classes for the given ontology class. |
190 | | - """ |
191 | | - return self.get_owl_items(owl_class.children()) |
192 | | - |
193 | | - def get_parents(self, owl_class: Any) -> List: |
194 | | - """ |
195 | | - Retrieves the parents of the ontology class. |
196 | | -
|
197 | | - Parameters: |
198 | | - owl_class (Any): The ontology class whose parents are to be retrieved. |
199 | | -
|
200 | | - Returns: |
201 | | - List: A list of parent classes for the given ontology class. |
202 | | - """ |
203 | | - return self.get_owl_items(owl_class.parents()) |
204 | | - |
205 | | - def get_synonyms(self, owl_class: Any) -> List: |
206 | | - """ |
207 | | - Retrieves synonyms for the ontology class. |
208 | | -
|
209 | | - Parameters: |
210 | | - owl_class (Any): The ontology class whose synonyms are to be retrieved. |
211 | | -
|
212 | | - Returns: |
213 | | - List: An empty list as no synonyms are implemented for this ontology class. |
214 | | - """ |
215 | | - return [] |
216 | | - |
217 | | - def get_comments(self, owl_class: Any) -> List: |
218 | | - """ |
219 | | - Retrieves comments for the ontology class. |
220 | | -
|
221 | | - Parameters: |
222 | | - owl_class (Any): The ontology class whose comments are to be retrieved. |
223 | | -
|
224 | | - Returns: |
225 | | - List: An empty list as no comments are implemented for this ontology class. |
226 | | - """ |
227 | | - return [] |
228 | | - |
229 | | - def get_owl_classes(self, ontology: Any) -> Any: |
230 | | - """ |
231 | | - Retrieves all classes from the ontology. |
232 | | -
|
233 | | - Parameters: |
234 | | - ontology (Any): The ontology whose classes are to be retrieved. |
235 | | -
|
236 | | - Returns: |
237 | | - Any: The classes of the ontology. |
238 | | - """ |
239 | | - return ontology.all_classes |
240 | | - |
241 | | - def load_ontology(self, input_file_path: str) -> Any: |
242 | | - """ |
243 | | - Loads an ontology from the specified file. |
244 | | -
|
245 | | - Parameters: |
246 | | - input_file_path (str): The path to the ontology file to be loaded. |
247 | | -
|
248 | | - Returns: |
249 | | - Any: The loaded ontology. |
250 | | - """ |
251 | | - ontology = ontospy.Ontospy(input_file_path, verbose=False) |
252 | | - return ontology |
253 | | - |
| 129 | + pass |
254 | 130 |
|
255 | 131 | class MatOntoOntology(BaseOntologyParser): |
256 | 132 | """ |
|
0 commit comments