Sunday, December 16, 2018

Self similarity of a TedX talk

I watched this TedX talk, and found it interesting.

I then wondered if the talk itself had interesting self-similarity... so after much bashing keys and trying to figure out python, I got the following image. The image shows white pixels where a word in the x and y position of the transcript match.

Here's the code that parsed the text and generated the image

with open(b'C:\Users\Mike Warot\Desktop\Pop Music is Stuck on Repeat - transcript.txt') as myfile:
    text = myfile.readlines()
# text now countains all the lines of text, including newlines

data = [];
for line in text:
# data now contains a list of all the words in the file

print(len(data),"words loaded");


from PIL import Image
a ="RGB",(len(data),len(data)))
for x in range(1,len(data)):
    for y in range(1,len(data)):
        if data[x]==data[y]:
            a.putpixel((x,y),(255,255,255));'C:\Users\Mike Warot\Desktop\Pop Music is Stuck on Repeat - transcript.png',"PNG")

No comments: