-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVikaObjectHelper.py
More file actions
33 lines (27 loc) · 979 Bytes
/
VikaObjectHelper.py
File metadata and controls
33 lines (27 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
class VikaObjectHelper:
def __init__(self):
path = "/home/seb/vika/wordLists/objectsWordList.json"
with open(path, "r") as objects_file:
self.objects_json = json.load(objects_file)
'''gets the synonyms for a given object (object as dict)'''
def GetObjectSynonyms(self, obj):
objectIds = list()
synonyms = list()
objectIds.extend(obj["s"])
for objectId in objectIds:
v = self.FastGetObjectById(objectId)
synonyms.append(v)
return synonyms
'''Gets object as dict by name'''
def GetObject(self, objectName):
for obj in self.objects_json:
if obj["n"] in objectName:
return obj
return None
'''Gets object as dict by Id'''
def FastGetObjectById(self, objectId):
try:
return self.objects_json[int(objectId)]
except IndexError:
print("FastGetObjectById IndexError")