{ "cells": [ { "cell_type": "markdown", "id": "66f72396-0cf1-41cf-a486-2930d2ad1652", "metadata": {}, "source": [ "# highlight_map\n", "Give a string with the name of the image-file that was annotated with the Annotation Compass; Give a target-word; Return a string that includes all annotation-texts plus html-tags that place them back into their original position while highlighting the annotation-texts that include the target." ] }, { "cell_type": "code", "execution_count": 1, "id": "2d179f96-2f4c-419f-97d9-9ea833bfc4b3", "metadata": {}, "outputs": [], "source": [ "from urllib.request import urlopen\n", "import json" ] }, { "cell_type": "code", "execution_count": 2, "id": "9bd8860a-9967-49d5-a74a-b5de669dfe6d", "metadata": {}, "outputs": [], "source": [ "def highlight_map(image: str, target: str ) -> str:\n", " \n", " \"\"\"Give a string with the name of the image-file that was annotated with the Annotation Compass; Give a target-word; Return a string that includes all annotation-texts plus html-tags that place them back into their original position while highlighting the annotation-texts that include the target.\"\"\" \n", "\n", " url = f\"https://hub.xpub.nl/soupboat/generic-labels/get-labels/?image={image}\"\n", " response = urlopen(url)\n", " data_json = json.loads(response.read()) \n", " \n", " filtered_map = ''\n", " for label in data_json['labels']:\n", " if target in label['text']:\n", " highlight_tag = f'

{ label[\"text\"] }

'\n", " filtered_map = filtered_map + highlight_tag\n", " else:\n", " html_tag = f'

{ label[\"text\"] }

'\n", " filtered_map = filtered_map + html_tag\n", " \n", " return filtered_map" ] }, { "cell_type": "markdown", "id": "1094ed8e-1387-481e-b612-9a8cc81d5c18", "metadata": {}, "source": [ "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.\n", "\n", " Example for a label:\n", "\n", " {'image': 'map.jpg',\n", " 'position': {'x': 12, 'y': 97},\n", " 'size': {'width': 43, 'height': 18},\n", " 'text': 'This is a text! Is this a text?',\n", " 'timestamp': 'Wed, 01 Dec 2021 14:04:00 GMT',\n", " 'userID': 5766039063}\n", "\n", "\n", "If interested in all annotations that include a specific target, highlight_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 and a target-word. The output is a string that includes all annotation-texts plus html-tags that place them back into their original position while highlighting the annotation-texts that include the target.\n", "\n", "How to get a json-file with annotation-labels?\n", "\n", " https://hub.xpub.nl/soupboat/generic-labels/\n", "The Annotation Compass allows people to uplaod an image and ask others to annotate it. A json-file of the annotations is provided." ] }, { "cell_type": "markdown", "id": "2c3e992a-317b-4433-8c3b-9efcedea575d", "metadata": { "tags": [] }, "source": [ "## Examples\n", "\n", "In this example, the function highlights all annotation-texts that include a specific target." ] }, { "cell_type": "code", "execution_count": 7, "id": "e3d7e97b-0089-4c29-a2c1-9ef823ff2e37", "metadata": { "scrolled": true, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "'

here, someone called my behaviour \"strange\"

윰보에서 장을 보고 집에 돌아오는 길. 두 명의 남자 가 다가왔어. 나는 낑낑대며 나의 일주일간 식량을 옮기고 있었지. 쾅!\\n큰 소리가 났고 나는 순간 움츠러들었어. \\n건너편에서 다가오던 남자 두명이 크게 웃더니 \\n나를 보며 Chino! Chino!라고 외쳤어. 시발.

the municipality of rotterdam (prince alexander) almost refused to approve my request of registration because the italian id card doesn\\'t have my sex written on it. \\nthey said that if i bring my birth certificate that states that im a male i can have my bsn otherwise.......... nope.

getting a text message from my good friend, telling me that she will not visit me in Rotterdam despite she promised me.

house viewing 2: meeting with some girls in the evening to see a room; felt super exposed and awkward. Later on, they rejected me.

I once went to view a house here but it didn\\'t have the floor. crap.

here, someone screamed at me \"move fucking chinee\"

other housing rejection situations here.\\n

a woman on the train showed me the middle finger the first day i arrived to rotterdam and i didn\\'t really understand why because she\\'s the one that was mean with me in the first place

at 22:01 a bald man kicked us out from the basketball court because we were noisy

here, someone screamed at me, right into my face, something I could not understand

the most unpleasant house viewing: my viewing overlapped with the previous person and I didn\\'t got the chance to connect with the ones living them. How could then they know who I am and even consider me for the room?

Stepped out at the wrong bus station and because the waiting time for the next bus was (a bit) long, Carmen and I decided to walk to Varia... Rejected by punctuality.

here, someone told me to move away

I had the most awkward house viewing here. The people barely talked to me and really let me know that they didn\\'t like me. Obviously, I did not get the room.

rejected by the police

my first house viewing: I was really hopeful about this one, actually, because I felt a connection with the girl. I waited 2 weeks to be rejected from this one.

here, someone told to stop looking at them

I had the most awkward house viewing here. The people barely talked to me and really let me know that they didn\\'t like me. Not surprisingly, I did not get the room.

어딘지 잘은 모르겠지만, Kralingen 쪽이었던 것 같아. bsn 거주등록을 위해 학교에 갔는데, 시청에서 나온 사람들이 나의 룸메이트 ID card가 필요하다며 거절했지. 나의 아침을 날렸어. 나의 룸메가 나에게 ID card 사진을 보내줬지만, 그들은 서명이 같지 않다면서 다시 거절했지.

i couldn\\'t eat anything from a spar because it was selling only non gluten-free products.

I felt rejection in Art Rotterdam 2019 when the parents of my boyfriend\\'s exgirlfriend came to visit my exboyfriends exhibition there and I felt kinda OUT OF PLACE? heheheh

Emma와 함께 프린트를 하러 갔는데, 그곳에 있는 instructor가 매우 불친절했어.

An old friend of mine that I know from my home country also studies at WDKA. I reached out to him and suggested to hang out soon. He didn\\'t want to.

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.

super nice sublet. I\\'ll be rejected in a month though.

i got ejected from a bike here. i was just trying to move through space, but bikes don\\'t like me

My bike got stolen here.

The first time I stayed overnight in Rotterdam, after a nice walk in the sun, I got stuck 2 hours at Centraal, because the Intercity direct broke down. I felt rejected by NS.

I also felt rejection in Art Rotterdam 2020 when someone I knew from a gallery decided not to say hello back after me saying HELLO.

💫💔💥🥐🍟🍕

missed a lot of trains

I felt rejected from some friends that made me a book but stop replying to my messages after my breakup.

my first no-credit-card experience

we were going to a friends house when we got trapped into the riot against covid restrictions and a car got on fire and it was super bad to see all the anger all these people had i felt small and sad and i just wanted to run as faster as i could

my second no-credit card experience in a super nice bar; however, they were ok with a bank transfer :D

People throwing firework at other people here during an anti corona demonstration.

I felt rejected here when the friend mentioned in n3 introduced me to someone else calling me \"Raquel\"

i got rejected from a skateboard here. it\\'s normal though because it\\'s always trying to reject you and you love it anyway

they called me and tried to get my bank details saying that my bsn number has been used for illigal and criminal activities in amsterdam

my wallet rejected me for about 10 mins heree. it fell from my pocket at albert heijn but we reunited at the customer service desk. it was intense.

house rejection\\n

'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "highlight_map('rejection_map.jpg', 'house')" ] }, { "cell_type": "code", "execution_count": null, "id": "ed9f5de3-451d-4dc5-8e9f-97228df73e11", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 5 }