1717class Option :
1818 """
1919 An option is a possible answer within a Classification object in
20- a Project's ontology.
20+ a Project's ontology.
2121
2222 To instantiate, only the "value" parameter needs to be passed in.
2323
@@ -41,11 +41,11 @@ def label(self):
4141
4242 @classmethod
4343 def from_dict (cls , dictionary : Dict [str , Any ]):
44- return Option (value = dictionary ["value" ],
44+ return cls (value = dictionary ["value" ],
4545 schema_id = dictionary .get ("schemaNodeId" , None ),
4646 feature_schema_id = dictionary .get ("featureSchemaId" , None ),
4747 options = [
48- Classification .from_dict (o )
48+ cls .from_dict (o )
4949 for o in dictionary .get ("options" , [])
5050 ])
5151
@@ -69,13 +69,13 @@ def add_option(self, option: 'Classification'):
6969@dataclass
7070class Classification :
7171 """
72- A classfication to be added to a Project's ontology. The
72+ A classfication to be added to a Project's ontology. The
7373 classification is dependent on the Classification Type.
7474
7575 To instantiate, the "class_type" and "instructions" parameters must
7676 be passed in.
7777
78- The "options" parameter holds a list of Option objects. This is not
78+ The "options" parameter holds a list of Option objects. This is not
7979 necessary for some Classification types, such as TEXT. To see which
8080 types require options, look at the "_REQUIRES_OPTIONS" class variable.
8181
@@ -120,16 +120,16 @@ def name(self):
120120
121121 @classmethod
122122 def from_dict (cls , dictionary : Dict [str , Any ]):
123- return Classification (
124- class_type = Classification .Type (dictionary ["type" ]),
123+ return cls (
124+ class_type = cls .Type (dictionary ["type" ]),
125125 instructions = dictionary ["instructions" ],
126126 required = dictionary .get ("required" , False ),
127127 options = [Option .from_dict (o ) for o in dictionary ["options" ]],
128128 schema_id = dictionary .get ("schemaNodeId" , None ),
129129 feature_schema_id = dictionary .get ("featureSchemaId" , None ))
130130
131131 def asdict (self ) -> Dict [str , Any ]:
132- if self .class_type in Classification ._REQUIRES_OPTIONS \
132+ if self .class_type in self ._REQUIRES_OPTIONS \
133133 and len (self .options ) < 1 :
134134 raise InconsistentOntologyException (
135135 f"Classification '{ self .instructions } ' requires options." )
@@ -160,13 +160,13 @@ class Tool:
160160 To instantiate, the "tool" and "name" parameters must
161161 be passed in.
162162
163- The "classifications" parameter holds a list of Classification objects.
163+ The "classifications" parameter holds a list of Classification objects.
164164 This can be used to add nested classifications to a tool.
165165
166166 Example(s):
167167 tool = Tool(
168168 tool = Tool.Type.LINE,
169- name = "Tool example")
169+ name = "Tool example")
170170 classification = Classification(
171171 class_type = Classification.Type.TEXT,
172172 instructions = "Classification Example")
@@ -200,11 +200,11 @@ class Type(Enum):
200200
201201 @classmethod
202202 def from_dict (cls , dictionary : Dict [str , Any ]):
203- return Tool (name = dictionary ['name' ],
203+ return cls (name = dictionary ['name' ],
204204 schema_id = dictionary .get ("schemaNodeId" , None ),
205205 feature_schema_id = dictionary .get ("featureSchemaId" , None ),
206206 required = dictionary .get ("required" , False ),
207- tool = Tool .Type (dictionary ["tool" ]),
207+ tool = cls .Type (dictionary ["tool" ]),
208208 classifications = [
209209 Classification .from_dict (c )
210210 for c in dictionary ["classifications" ]
@@ -287,9 +287,9 @@ class OntologyBuilder:
287287 for making Project ontologies from scratch. OntologyBuilder can also
288288 pull from an already existing Project's ontology.
289289
290- There are no required instantiation arguments.
290+ There are no required instantiation arguments.
291291
292- To create an ontology, use the asdict() method after fully building your
292+ To create an ontology, use the asdict() method after fully building your
293293 ontology within this class, and inserting it into project.setup() as the
294294 "labeling_frontend_options" parameter.
295295
@@ -303,14 +303,14 @@ class OntologyBuilder:
303303 tools: (list)
304304 classifications: (list)
305305
306-
306+
307307 """
308308 tools : List [Tool ] = field (default_factory = list )
309309 classifications : List [Classification ] = field (default_factory = list )
310310
311311 @classmethod
312312 def from_dict (cls , dictionary : Dict [str , Any ]):
313- return OntologyBuilder (
313+ return cls (
314314 tools = [Tool .from_dict (t ) for t in dictionary ["tools" ]],
315315 classifications = [
316316 Classification .from_dict (c )
@@ -337,7 +337,7 @@ def _update_colors(self):
337337 @classmethod
338338 def from_project (cls , project : Project ):
339339 ontology = project .ontology ().normalized
340- return OntologyBuilder .from_dict (ontology )
340+ return cls .from_dict (ontology )
341341
342342 def add_tool (self , tool : Tool ):
343343 if tool .name in (t .name for t in self .tools ):
0 commit comments