Hello

I have been super busy creating a system to analyse the words used to describe wine. I also want to analyse the words used to describe gin, but wine flavour descriptions are more available and varied, the copywriting of which has become quite an art as we try to figure out which wine to pair with food. Unlike wine, gin isn’t really paired with food, although I am sure there is an area for it.

Screen Shot 2015-05-27 at 21.51.45

I also prettied up my Ginfographic website a touch.

This page serves as a form and an analysis of sorts in one. Firstly, I created some models to accept drink data – in fact, there’s quite a few of them. Firstly, there is the drink model. This contains the data of the wine bottle – i’ve also added a drinktype just in case I choose to look at Gin too. Thinking ahead as always. This links to the drinkwords model, which is all of the words submitted regardless of the drink. I’ve included a prevalence field, as well as a definition, which i’ve filled using the WordNik API. The prevalence basically counts how many times this word crops up. Thanks to WordNik, this then links to a speech part table. The speech part is the word’s status as a verb, noun, preposition, etc. From the speechparts table, you can also view all of the words falling under that category.

I thought that looking at the speech part was a good place to start with analysing the words. This seems heavily automated, and I guess it is, but considering i’m looking at how computers reflect natural systems, it seemed suited to automate it – i’m trying to remove as much of my own subjectivity from this as possible.

When a description is entered, this is split via each space on the server side, then analysed – the recipe simply holds the wine data, and this is submitted straight through. Then, each word is compared to the database to see if it exists, if it does, it retrieves the remaining database record and increases the prevalence by 1, if not it is added as a new word. This record is then passed through some functions created with the WordNik dictionary API to grab the definition and it’s speech part. The page is returned with the new words added to the data bars below the form, and the progress bar indicates the words prevalence.

Looking at it now, maybe I could have removed the conjunctions and prepositions, as these seem pretty arbitrary. The most prevalent words are, unsurprisingly,

Screen Shot 2015-05-27 at 22.08.35

ripe
fruit
fresh
palate
flavours
finish
subtle

‘Flavours’ and ‘palate’ being used to describe flavour, hmm. I don’t really like this route of analysing the words, then again maybe I do because it is a proof of concept. The copy is being likened to the ingredients of the wine, such as ripe and fruit, and to a certain extent, fresh (connotations of freshly picked ripe fruit, orchards, sunny weather, the best possible produce). The use of ‘subtle’, almost connoting a softly lingering taste, deploying a likeness of the wine in our mouths, with ‘finish’ referring to the end flavour as a whole. Very clever stuff, very generalised and very commodified (in a good way I promise!).

Looking at the data, nouns are used the most, referring to the ingredients used, our orifices (mouth, nose), some directional nouns (corner, the journey through our senses I guess) and colour. Closely followed by adjectives (luxurious, smooth, plummy [referring to a noun again]).

Lo and behold, I released these with the API:
Nouns: http://ginfographic.chez.io/api/v1.0/speechpart/1/words/
Adjectives: http://ginfographic.chez.io/api/v1.0/speechpart/5/words/

Screen Shot 2015-05-27 at 22.22.52

After this, I thought a good exercise would be to implement this data in Processing. Finally putting pen to paper. I decided to create a simple word cloud using this data, and also thought it might be a good time to start using Object Oriented Programming within Processing, as I enjoy it so much in Python.

Screen Shot 2015-05-27 at 22.25.37

Luckily this was quite a small program, so I can include the code below. These are two classes, Word and SpeechPart. These act as blueprints I can create objects with, and I could add all of the resulting Word objects as an ArrayList to each SpeechPart. It was surprisingly pleasant to parse the JSON data in Processing, I envisaged it being more of a painful experience, but that was txt file memories, this is the wonderful world of JavaScript Object Notation.

There is no order to this sketch, it blurts out each word at a random location with the speech part name overlaid, so I need to work on my positioning. But still, i’m really excited to actually implement my database information and API with Processing, and for it to work!

This sketch has been quite heavily commented as I sent it to my friend to play with, but it’s helping me remember how I made it to begin with. Note to self: comment stuff.

/*
I made a web app that takes Wine label descriptions, splits it up word for word, and assigns each word to its
speech part (verb, noun etc) using a dictionary API (Wordnik I think), and also storing the word description
for later data visualisations. I made my own API from this data, and this is my first attempt at getting the data
actually into processing and visualising it some way. This simply shows each speech part in red, and every word
collected in white.
*/

// Setting variables here
JSONObject json;
Word[] myWords;
SpeechPart[] speechParts;
PFont myFont;

// This is the URL of my API, it's in JSON format http://www.json.org/
String baseURL = "http://ginfographic.chez.io/api/v1.0/speechparts/";

void setup() {
// Setting up environment aesthetically
size(800, 600);
background(0);
myFont = createFont("Georgia", 12);
textFont(myFont);
fill(255, 0, 0, 100);

//Initiate getSpeechPartsFunction
getSpeechParts();

}

void draw() {
// Couldn't decide what to put here
}

void getSpeechParts() {
//Load URL as JSONObject
json = loadJSONObject("http://ginfographic.chez.io/api/v1.0/speechparts/");

//Within my JSONObject {} are arrays [] of information, you'll see here http://ginfographic.chez.io/api/v1.0/speechparts/
//So I need to navigate them accordingly as I work through the data - this part is an array []
JSONArray result = json.getJSONArray("speech_parts");

//This is where it gets complicated, below I created a Class called SpeechPart. A Class is basically a blueprint
//To feed information to. On top of that, i'm going to initiate an array[] of them! Depending on how many results
//I have
SpeechPart[] speechParts = new SpeechPart[result.size()];

//Looping over the speech_parts ('verbs' and stuff)
for (int i = 0; i < result.size(); i++){ JSONObject part = result.getJSONObject(i); //Get speech part name, i.e 'verb' String name = part.getString("name"); //Creating a SpeechPart Object speechParts[i] = new SpeechPart(name); //Complicated again - below, I also have a Word class. This is a blueprint for each word that belongs to each //Speech Part, so 'move' is a verb. Therefore Word belongs to Speech Part, and because there are multiple //Words for each Speech Part, I must have an array of them, this pre initiates them ArrayList allWords = new ArrayList();

//Grabbing the words from the JSON API, these appear as an array in the JSON, ready to made Objects with
JSONArray words = part.getJSONArray("words");

Word[] myWords = new Word[words.size()];

//Going to loop over each word now
for (int x = 0; x < words.size(); x++) { //Grab each word JSONObject{} JSONObject word = words.getJSONObject(x); //Setting the word name (i.e 'move') definition, and prevalence to the var wordName String wordName = word.getString("word"); String wordDefinition = word.getString("definition"); int wordGinCount = word.getInt("prevalence_gin"); int wordWineCount = word.getInt("prevalence_wine"); int xPos = x + 20; //Appending a new Word Object to the ArrayList of Word Classes allWords.add(new Word(wordName, wordDefinition, name, wordGinCount, wordWineCount, xPos)); } //Setting the SpeechPart word list to the Array List of words speechParts[i].words = allWords; //Calling a method from SpeechPart to display the data speechParts[i].display(); } } /* This is where I have initiated the Classes. These are basically blueprints that I can feed data into over and over again to get slightly varied results, depending on the parameters */ class Word { String name; String definition; String speechPart; int prevalenceGin; int prevalenceWine; float x; float y; Word(String wordName, String wordSpeechPart, String wordDefinition, int wordPrevalenceGin, int wordPrevalenceWine, float wordPosx) { name = wordName; definition = wordDefinition; speechPart = wordSpeechPart; prevalenceGin = wordPrevalenceGin; prevalenceWine = wordPrevalenceWine; x = random(0, width); y = random(0, height); } //A function within a Class is called a method. This could later be called as Word.display() //Here i'm just printing each word in white, and giving it a random position value void display() { textFont(myFont); fill(255, 255, 255, 100); text(name, x, y); } } class SpeechPart { String name; ArrayList words;
float x;
float y;

SpeechPart(String partName) {
name = partName;
}

//Remember how I called this earlier as speechParts[i].display()? This displays each Speech Part in red
void display() {
println(name);
x = random(0, width);
y = random(0, height);

textFont(myFont);
fill(255, 0, 0, 100);
text(name, x, y);

//And this is a super quick loop that I love, we passed the ArrayList of Word classes as a parameter to
//The object, so each list of words relevent to the speech parts are available for us to use. So for each
//word Class in the array of Classes called words, call the display method.
for (Word word : words) {
word.display();
}
}

}

So, here it is, I guess. The limits of words. Our language has a pretty huge vocabulary, 1,000,000 in total, half of those we use routinely. But still it limits us when describing sensations in our mouths, the memories they evoke, how they make us feel, people they remind us of, what we’re looking at when we taste them, how they feel on our tongue, how eating something wonderful will make your muscles relax and maybe make you emit an appreciative noise, the camaraderie of eating something delicious with someone, how it feels to see all of this on someone you have created food for.