6.5 KiB
individual_map¶
give a string with the name of the image-file that was annotated with the Annotation Compass; Select one or more specific targets and return a list of all labels that include these targetsselect one or more specific users and return a list of all labels from these users.
from urllib.request import urlopen import json
def individual_map(image: str, users: list ) -> list: """give a string with the name of the image-file that was annotated with the Annotation Compass; Select one or more specific targets and return a list of all labels that include these targetsselect one or more specific users and return a list of all labels from these users.""" url = f"https://hub.xpub.nl/soupboat/generic-labels/get-labels/?image={image}" response = urlopen(url) data_json = json.loads(response.read()) filtered_map = [] for label in data_json['labels']: for user in users: if label['userID'] == user: filtered_map.append(label) return filtered_map
This function was built for a project where individuals are invited to add their annotations on a map using the Annotation Compass. Each annotation-label is stored in a json-file and includes the annotation-text itself, but also the name of the image-file as well as the position, size, index, timestamp and userID of the annotation.
Example for a label:
{'image': 'map.jpg',
'position': {'x': 12, 'y': 97},
'size': {'width': 43, 'height': 18},
'text': 'This is a text! Is this a text?',
'timestamp': 'Wed, 01 Dec 2021 14:04:00 GMT',
'userID': 5766039063}
If interested in all annotations of one or more specific users, individual_map() can help. The function needs a string with the name of the of the image-file that was annotated with the annotation compass tool as well as one or more specific userIDs to target. The output is a list of all labels from the users of interest.
How to get a json-file with annotation-labels?
https://hub.xpub.nl/soupboat/generic-labels/
The Annotation Compass allows people to uplaod an image and ask others to annotate it. A json-file of the annotations is provided.
Examples¶
In this example, the function returns all annotation-labels of two specific users.
individual_map('rejection_map.jpg', ['8112114057', '6004575665'])
[{'image': 'rejection_map.jpg', 'position': {'x': 63.9896, 'y': 34.2958}, 'size': {'height': 3.23944, 'width': 2.90155}, 'text': 'here, someone called my behaviour "strange"', 'timestamp': 'Wed, 15 Dec 2021 11:36:04 GMT', 'userID': '8112114057'}, {'image': 'rejection_map.jpg', 'position': {'x': 39.3264, 'y': 46.831}, 'size': {'height': 6.19718, 'width': 9.2228}, 'text': 'here, someone screamed at me "move fucking chinee"', 'timestamp': 'Wed, 15 Dec 2021 11:36:55 GMT', 'userID': '8112114057'}, {'image': 'rejection_map.jpg', 'position': {'x': 36.5285, 'y': 54.2958}, 'size': {'height': 1.69014, 'width': 3.31606}, 'text': 'here, someone screamed at me, right into my face, something I could not understand', 'timestamp': 'Wed, 15 Dec 2021 11:37:37 GMT', 'userID': '8112114057'}, {'image': 'rejection_map.jpg', 'position': {'x': 42.5389, 'y': 45.7042}, 'size': {'height': 13.662, 'width': 23.9378}, 'text': 'here, someone told me to move away', 'timestamp': 'Wed, 15 Dec 2021 11:38:04 GMT', 'userID': '8112114057'}, {'image': 'rejection_map.jpg', 'position': {'x': 39.1192, 'y': 36.2676}, 'size': {'height': 11.6901, 'width': 20.4145}, 'text': 'here, someone told to stop looking at them', 'timestamp': 'Wed, 15 Dec 2021 11:38:45 GMT', 'userID': '8112114057'}, {'image': 'rejection_map.jpg', 'position': {'x': 46.3713, 'y': 58.4289}, 'size': {'height': 6.99541, 'width': 15.1055}, 'text': 'somewhere between this line i lost my ID card. and I really wasnt aware that this could linger a lot my registration to the municipality. This kinda triggered but feeling for me, as I felt a lot disorented here, having no formal document verifying who I am and feeling guilty tat I am still not registered.', 'timestamp': 'Wed, 15 Dec 2021 11:40:54 GMT', 'userID': '6004575665'}]