@@ -22,7 +22,7 @@ class Option:
2222 value : str
2323 schema_id : Optional [str ] = None
2424 feature_schema_id : Optional [str ] = None
25- nested_classes : List [Classification ] = field (default_factory = list )
25+ options : List [Classification ] = field (default_factory = list )
2626
2727 @property
2828 def label (self ):
@@ -34,7 +34,7 @@ def to_dict(self,for_different_project=False) -> Dict[str, str]:
3434 "featureSchemaId" : None if for_different_project else self .feature_schema_id ,
3535 "label" : self .label ,
3636 "value" : self .value ,
37- "options" : [classification .to_dict (for_different_project ) for classification in self .nested_classes ]
37+ "options" : [classification .to_dict (for_different_project ) for classification in self .options ]
3838 }
3939
4040 @classmethod
@@ -46,14 +46,14 @@ def has_nested_classifications(dictionary: Dict[str,str]):
4646 value = dictionary ["value" ],
4747 schema_id = dictionary ["schemaNodeId" ],
4848 feature_schema_id = dictionary ["featureSchemaId" ],
49- nested_classes = has_nested_classifications (dictionary )
49+ options = has_nested_classifications (dictionary )
5050 )
5151
5252 def add_nested_class (self , * args , ** kwargs ):
5353 new_classification = Classification (* args , ** kwargs )
54- if new_classification .instructions in (classification .instructions for classification in self .nested_classes ):
54+ if new_classification .instructions in (classification .instructions for classification in self .options ):
5555 raise InconsistentOntologyException (f"Duplicate nested classification '{ new_classification .instructions } ' for option '{ self .label } '" )
56- self .nested_classes .append (new_classification )
56+ self .options .append (new_classification )
5757 return new_classification
5858
5959@dataclass
@@ -207,47 +207,8 @@ def build(self, for_different_project=False):
207207
208208 return {"tools" : all_tools , "classifications" : all_classifications }
209209
210- '''
211- EVERYTHING BELOW THIS LINE IS JUST FOR SELF TESTING
212- '''
213-
214- def print_stuff ():
215- tools = o .tools
216- classifications = o .classifications
217-
218- print ("tools\n " )
219- for tool in tools :
220- print ("\n " ,tool )
221- print ("\n classifications\n " )
222- for classification in classifications :
223- print ("\n " ,classification )
224-
225210if __name__ == "__main__" :
226- os .system ('clear' )
227- apikey = os .environ ['apikey' ]
228- client = Client (apikey )
229- project = client .get_project ("ckhchkye62xn30796uui5lu34" )
230-
231- # client = Client(apikey)
232- # project = client.get_project("ckkyi8ih56sc207570tb35of1")
233-
234- o = Ontology ().from_project (project )
235-
236-
237- #create a Point tool and add a nested dropdown in it
238- # tool = o.add_tool(tool = Tool.Type.POINT, name = "Example Point Tool")
239- # nested_class = tool.add_nested_class(class_type = Classification.Type.DROPDOWN, instructions = "nested class")
240- # dropdown_option = nested_class.add_option(value="answer")
241-
242- # tool = o.add_tool(tool = Tool.Type.NER, name="NER value")
243-
244- #to old existing project
245- frontend = list (client .get_labeling_frontends (where = LabelingFrontend .name == "Editor" ))[0 ]
246- project .setup (frontend , o .build (for_different_project = False ))
247-
248- #to a different project
249- # other_project = client.get_project("ckkzzw5qk1yje0712uqjn0oqs")
250- # other_project.setup(frontend, o.build(for_different_project=True))
211+ pass
251212
252213
253214
0 commit comments