diff --git a/2018/word2vec/situation-embeddings/embeddings-inspector.py b/2018/word2vec/situation-embeddings/embeddings-inspector.py new file mode 100644 index 0000000000000000000000000000000000000000..cb79a867f75ca1878b9c3c81f215bd027bab461b --- /dev/null +++ b/2018/word2vec/situation-embeddings/embeddings-inspector.py @@ -0,0 +1,132 @@ +# Table embeddings +# written during Algolit +# 13 April 2018 +# Notes: https://pad.constantvzw.org/p/130418_algolit_word2vec2 + +import os +from collections import Counter +import pprint +import random + +pp = pprint.PrettyPrinter(indent=4) + +filename = 'embeddings.train' +text = open('{}.txt'.format(filename),'r').readlines() +# [['empty, bankcard, pen holder\n'], +# ['bankcard, pen holder, notebook\n'], +# ['pen holder, notebook, keys\n']] + +main = {} +# main = { +# 'human' { +# Counter({ +# 'cup' : 1, +# 'laptop' : 1, +# }) +# } +# } + +for ngram in text: + ngram = ngram.split(', ') + center = ngram[1] + left = ngram[0] + right = ngram[2].replace('\n','') + + if not center in main: + main[center] = Counter() + main[center][left] +=1 + main[center][right] +=1 + +pp.pprint(main) +print('************') + +numbers = {1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five', 6 : 'six', 7 : 'seven', 8 : 'eight', 9 : 'nine', 10 : 'ten'} +determiners = {3 : 'a few', 5 :'many', 7: 'a lot of', 6 : 'most', 2 : 'some', 1 : 'any', 4 : 'enough'} + +sentences = [] +x = 0 +for cw, c in main.items(): + x += 1 + wwords = [] + wwordsandcounts = [] + wwordsanddeterminers = [] + for word, count in c.items(): + wwords.append(word) + + if count > 1: + word = word+'s' + determiner = determiners[count] + + wwordsandcounts.append(numbers[count] + ' ' + word) + wwordsanddeterminers.append(determiner + ' ' + word) + + intro = '' + templates = [ + 'What makes a {0} a {0}, is its closeness to {1} and {2}.'.format(cw, ', '.join(wwordsanddeterminers[:-1]), wwordsanddeterminers[-1]), + 'You can identify a {} when it appears in the company of {} and {}.'.format(cw, ', '.join(wwordsandcounts[:-1]), wwordsandcounts[-1]), + 'A {} can be recognized when it lies next to a {} and a {}.'.format(cw, ', '.join(wwords[:-1]), wwords[-1]) + ] + + if x == 5: + sentences.append('\nMeanwhile ...\n') + x = 0 + + s = random.choice(templates) + sentences.append(s) + +for sentence in sentences: + print(sentence) + +head = ''' + + + + + + +

situation embeddings

+''' + +foot = ''' + +''' + +images = [f for f in os.listdir('./img/{}'.format(filename))] + +with open('{}.html'.format(filename),'w') as html: + html.write(head) + html.write(''.format(filename, random.choice(images))) + i = 0 + for sentence in sentences: + if 'Meanwhile' in sentence: + html.write('

'+sentence+'

') + print(i, i % 2) + if i % 2 == 0: + html.write(''.format(filename, random.choice(images))) + else: + html.write(''.format(filename, random.choice(images))) + else: + html.write('

'+sentence+'

') + i += 1 + html.write(foot) + print('*html file written*') \ No newline at end of file diff --git a/2018/word2vec/situation-embeddings/embeddings.table.html b/2018/word2vec/situation-embeddings/embeddings.table.html new file mode 100644 index 0000000000000000000000000000000000000000..b2c00f17fee370f32328bacc833c6cc22bd67bc4 --- /dev/null +++ b/2018/word2vec/situation-embeddings/embeddings.table.html @@ -0,0 +1,38 @@ + + + + + + + +

situation embeddings

+

You can identify a hand when it appears in the company of one charger and one keys.

A cup can be recognized when it lies next to a charger, mouse, laptop, notebook, phone and a human.

What makes a box a box, is its closeness to any charger and any laptop.

You can identify a keys when it appears in the company of one hand, one notebook, one bottle and one extension block.

+Meanwhile ... +

What makes a pen holder a pen holder, is its closeness to any bankcard and any notebook.

You can identify a lego piece when it appears in the company of one laptop and one extension block.

A bowl can be recognized when it lies next to a sheet and a human.

A plate can be recognized when it lies next to a cable and a laptop.

What makes a notebook a notebook, is its closeness to any cup, any keys, any pen holder and any human.

+Meanwhile ... +

You can identify a extension block when it appears in the company of one lego piece and one keys.

What makes a charger a charger, is its closeness to any hand, some cups, any sheet, any box, any bottle, any laptop and any speaker.

What makes a sheet a sheet, is its closeness to any bowl and any charger.

What makes a bottle a bottle, is its closeness to any charger and any keys.

You can identify a speaker when it appears in the company of one charger and one phone.

+Meanwhile ... +

A bankcard can be recognized when it lies next to a empty and a pen holder.

What makes a cable a cable, is its closeness to any plate and any laptop.

A laptop can be recognized when it lies next to a lego piece, cup, box, charger, laptop, plate, cable and a human.

What makes a human a human, is its closeness to any cup, any mouse, any bowl, a few laptops, any notebook, any phone and enough humans.

You can identify a phone when it appears in the company of one cup and one speaker.

+Meanwhile ... +

What makes a mouse a mouse, is its closeness to any cup and any human.

+ diff --git a/2018/word2vec/situation-embeddings/embeddings.table.txt b/2018/word2vec/situation-embeddings/embeddings.table.txt new file mode 100644 index 0000000000000000000000000000000000000000..a11fe3e390ec13eebacc01beb33fa2e34fad5207 --- /dev/null +++ b/2018/word2vec/situation-embeddings/embeddings.table.txt @@ -0,0 +1,40 @@ +empty, bankcard, pen holder +bankcard, pen holder, notebook +pen holder, notebook, keys +notebook, keys, hand +keys, hand, charger +hand, charger, box +charger, box, laptop +box, laptop, cup +laptop, cup, mouse +cup, mouse, human +mouse, human, laptop +human, laptop, plate +laptop, plate, cable +plate, cable, laptop +cable, laptop, human +laptop, human, bowl +human, bowl, sheet +bowl, sheet, charger +sheet, charger, bottle +charger, bottle, keys +bottle, keys, extension block +keys, extension block, lego piece +extension block, lego piece, laptop +lego piece, laptop, human +laptop, human, human +human, human, notebook +human, notebook, cup +notebook, cup, phone +cup, phone, speaker +phone, speaker, charger +speaker, charger, cup +charger, cup, laptop +cup, laptop, charger +laptop, charger, cup +charger, cup, laptop +cup, laptop, laptop +laptop, laptop, cup +laptop, cup, human +cup, human, human +human, human, phone diff --git a/2018/word2vec/situation-embeddings/embeddings.train.html b/2018/word2vec/situation-embeddings/embeddings.train.html new file mode 100644 index 0000000000000000000000000000000000000000..f1c712e249122f5cbfa9904d0c62f3dc74285007 --- /dev/null +++ b/2018/word2vec/situation-embeddings/embeddings.train.html @@ -0,0 +1,32 @@ + + + + + + + +

situation embeddings

+

What makes a human a human, is its closeness to any window and any chair.

You can identify a backpack when it appears in the company of one feet and one trash bin.

What makes a trash bin a trash bin, is its closeness to any backpack, some windows and any nothing.

A nothing can be recognized when it lies next to a feet, nothing, trash bin and a aisle.

+Meanwhile ... +

A feet can be recognized when it lies next to a backpack and a nothing.

What makes a window a window, is its closeness to any human, some trash bins and any chair.

You can identify a chair when it appears in the company of one human, two aisles and three chairs.

You can identify a aisle when it appears in the company of two nothings and two chairs.

+ diff --git a/2018/word2vec/situation-embeddings/embeddings.train.txt b/2018/word2vec/situation-embeddings/embeddings.train.txt new file mode 100644 index 0000000000000000000000000000000000000000..031d3fa5b09d6a546a641dbb9692af294e98b366 --- /dev/null +++ b/2018/word2vec/situation-embeddings/embeddings.train.txt @@ -0,0 +1,15 @@ +chair, chair, aisle +chair, aisle, chair +aisle, chair, chair +chair, chair, human +chair, human, window +human, window, trash bin +window, trash bin, backpack +trash bin, backpack, feet +backpack, feet, nothing +feet, nothing, aisle, +nothing, aisle, nothing +aisle, nothing, nothing +nothing, nothing, trash bin +nothing, trash bin, window +trash bin, window, chair diff --git a/2018/word2vec/situation-embeddings/img/algolit-table-as-resource.jpg b/2018/word2vec/situation-embeddings/img/algolit-table-as-resource.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b986afbda6b0eb2a5edc6e2200d823658340c9e2 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/algolit-table-as-resource.jpg differ diff --git a/2018/word2vec/situation-embeddings/img/algolit-table.jpg b/2018/word2vec/situation-embeddings/img/algolit-table.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f9bd9de9685f9d93ed0d848077e6afc7a5971bfb Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/algolit-table.jpg differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0870.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0870.JPG new file mode 100644 index 0000000000000000000000000000000000000000..17e72ea723669d6b98c5a040bebfb3d22c3c9904 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0870.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0871.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0871.JPG new file mode 100644 index 0000000000000000000000000000000000000000..6e48011d1c829616f1307cd0206a46149de13b8b Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0871.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0873.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0873.JPG new file mode 100644 index 0000000000000000000000000000000000000000..3bdae88094dae0da9596cca4df55faba6eb3d158 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0873.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0874.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0874.JPG new file mode 100644 index 0000000000000000000000000000000000000000..14cbfe926ef6c7c72fbf51406ff8c07486052acf Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0874.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0875.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0875.JPG new file mode 100644 index 0000000000000000000000000000000000000000..34bfdf978e2e9928321ac27a60f298a0c3dab333 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0875.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0877.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0877.JPG new file mode 100644 index 0000000000000000000000000000000000000000..16c0b0781e1e543a353700b23eec003bee32e168 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0877.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0878.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0878.JPG new file mode 100644 index 0000000000000000000000000000000000000000..f35aa05c5faa6f14333523c2c97acc875c5bfbc9 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0878.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0879.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0879.JPG new file mode 100644 index 0000000000000000000000000000000000000000..b6ff733bb7f78e30489d519a0f91a051746dd24b Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0879.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0880.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0880.JPG new file mode 100644 index 0000000000000000000000000000000000000000..cb7dcdce43021799c22dfc824c393a5ff57711b5 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0880.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0881.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0881.JPG new file mode 100644 index 0000000000000000000000000000000000000000..091220d5e248e1658f8ba58cea9e7370c73e75e4 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0881.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0882.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0882.JPG new file mode 100644 index 0000000000000000000000000000000000000000..7c70c114b8f29b85eb07b78184fac2998a58ffe4 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0882.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0883.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0883.JPG new file mode 100644 index 0000000000000000000000000000000000000000..60421b9e1ec95fb84263da1d22ce215cf0c69de7 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0883.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0884.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0884.JPG new file mode 100644 index 0000000000000000000000000000000000000000..eeffbc39dfae33f8f9f4c4cb0f1e9e6144a1b1c6 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0884.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0886.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0886.JPG new file mode 100644 index 0000000000000000000000000000000000000000..4c58d824a98a880ca22455488be06f1d4696a6ce Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0886.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0887.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0887.JPG new file mode 100644 index 0000000000000000000000000000000000000000..da72540895ec4872af0d017a737c4639bae35bfe Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0887.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0889.JPG b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0889.JPG new file mode 100644 index 0000000000000000000000000000000000000000..acd4d00eb12899e348b8c34e90823f335678a232 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.table/DSC_0889.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0831.JPG b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0831.JPG new file mode 100644 index 0000000000000000000000000000000000000000..6fc7e0b7f9701a4b38e27d59ded281f9bbb37551 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0831.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0833.JPG b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0833.JPG new file mode 100644 index 0000000000000000000000000000000000000000..07fae80a57319457a4160397b021802ef08a469c Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0833.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0834.JPG b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0834.JPG new file mode 100644 index 0000000000000000000000000000000000000000..4a05d674e5d8a46eba894b2f0bc27be98f45ed14 Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0834.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0835.JPG b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0835.JPG new file mode 100644 index 0000000000000000000000000000000000000000..2f07c6190bbb2fe0194743b339c89ba11219d01b Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0835.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0836.JPG b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0836.JPG new file mode 100644 index 0000000000000000000000000000000000000000..2a590b01292dc7f58493230046618ebdcd31c23a Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0836.JPG differ diff --git a/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0837.JPG b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0837.JPG new file mode 100644 index 0000000000000000000000000000000000000000..3cf58ea32336158dcb631b8bc1cd9af410433f1a Binary files /dev/null and b/2018/word2vec/situation-embeddings/img/embeddings.train/DSC_0837.JPG differ