@@ -36,7 +36,7 @@ def to_dict(self,for_different_project=False) -> dict:
3636 "featureSchemaId" : None if for_different_project else self .feature_schema_id ,
3737 "label" : self .label ,
3838 "value" : self .value ,
39- "options" : [classification .to_dict () for classification in self .nested_classes ]
39+ "options" : [classification .to_dict (for_different_project ) for classification in self .nested_classes ]
4040 }
4141
4242 @classmethod
@@ -60,7 +60,6 @@ def add_nested_class(self, *args, **kwargs):
6060 self .nested_classes .append (new_classification )
6161 return new_classification
6262
63-
6463@dataclass
6564class Classification :
6665
@@ -125,6 +124,7 @@ class Type(Enum):
125124 POINT = "point"
126125 BBOX = "rectangle"
127126 LINE = "line"
127+ NER = "named-entity"
128128
129129 tool : Type
130130 name : str
@@ -164,8 +164,6 @@ def add_nested_class(self, *args, **kwargs):
164164 self .classifications .append (new_classification )
165165 return new_classification
166166
167-
168-
169167@dataclass
170168class Ontology :
171169
@@ -216,9 +214,6 @@ def build(self, for_different_project=False):
216214'''
217215EVERYTHING BELOW THIS LINE IS JUST FOR SELF TESTING
218216'''
219- def run ():
220- frontend = list (client .get_labeling_frontends (where = LabelingFrontend .name == "Editor" ))[0 ]
221- project .setup (frontend , o .build (for_different_project = False ))
222217
223218def print_stuff ():
224219 tools = o .tools
@@ -233,20 +228,29 @@ def print_stuff():
233228
234229if __name__ == "__main__" :
235230 os .system ('clear' )
236- # apikey = os.environ['apikey']
237- # client = Client(apikey)
231+ apikey = os .environ ['apikey' ]
232+ client = Client (apikey )
233+ project = client .get_project ("ckhchkye62xn30796uui5lu34" )
234+
235+ # apikey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJja2szYTRhemRoN2x4MDcyNmU2MjFkamFlIiwib3JnYW5pemF0aW9uSWQiOiJja2szYTRheXlwdXlnMDczNjdzamZmanU5IiwiYXBpS2V5SWQiOiJja2wwNDJzMXFraGw0MDcwNnZmNTNodTNsIiwiaWF0IjoxNjEzMDAyNTU5LCJleHAiOjIyNDQxNTQ1NTl9.ViguRPw-Zv5KIs0Ho5VOjARUJtc5dTcQFFl4zGbBdbM'
236+ # client = Client(apikey)
237+ # project = client.get_project("ckkyi8ih56sc207570tb35of1")
238+
239+ o = Ontology ().from_project (project )
238240
239- # print("START\n")
240- # project = client.get_project("ckhchkye62xn30796uui5lu34")
241- # o = Ontology().from_project(project)
242241
243- # tool = o.add_tool(tool = Tool.Type.POINT, name = "first tool")
244- # nested_class = tool.add_nested_class(class_type = Classification.Type.DROPDOWN, instructions = "nested class")
245- # dropdown_option = nested_class.add_option(value="answer")
242+ #create a Point tool and add a nested dropdown in it
243+ tool = o .add_tool (tool = Tool .Type .POINT , name = "Example Point Tool" )
244+ nested_class = tool .add_nested_class (class_type = Classification .Type .DROPDOWN , instructions = "nested class" )
245+ dropdown_option = nested_class .add_option (value = "answer" )
246+
247+ #to old existing project
248+ frontend = list (client .get_labeling_frontends (where = LabelingFrontend .name == "Editor" ))[0 ]
249+ project .setup (frontend , o .build (for_different_project = False ))
246250
247- # print_stuff()
248- # o.build( )
249- # run( )
251+ #to a different project
252+ other_project = client . get_project ( "ckkzzw5qk1yje0712uqjn0oqs" )
253+ other_project . setup ( frontend , o . build ( for_different_project = True ) )
250254
251255
252256
0 commit comments