Seedlings_ is a project created by Qianxun Chen. It is an experimental web interface to explore the artistic value of algorithmic correlations of words in data driven text analysis. Words are planted as seeds and grow into different ‘plants’ with the help of Datamuse API. It is at once an ambient piece in which words and concepts are dislocated and recontextualized constantly, and a playground for the user to create linguistic immigrants and textual nomads.
You can find a demo here.(Best Viewed in Chrome)
Technical Breakdown of the project
- API: Datamuse
- Back end: Python Flask Framework
- Front end: d3.js
The following sections will be covered in the workshop.
-
Intro to datamuse, how to use the datamuse API
-
More about Seedlings_
-
Basic introduction to d3.js, a JavaScript library for producing dynamic, interactive data visualizations in web browsers.
-
Build Seedlings_ as a web app (?)
- Datamuse
- 1.1 What is datamuse
- 1.2 How to use datamuse?
- 1.3 APIs used in Seedlings_
- Seedlings_
- 2.1 Defining Plants
- 2.2 Visualization
- 2.3 Interface
- D3.js
- 3.1 What is d3.js
- 3.2 A basic visualization example
- How Seedlings_ works
- 4.1 Setups for seedlings
- 4.2 Plant from the Command Line!
- 4.3 Plant server using flask
- 4.4 PythonAnywhere
“The Datamuse API is a word-finding query engine for developers. You can use it in your apps to find words that match a given set of constraints and that are likely in a given context. ”
Major Data sources
- Corpus-based data:The Google Books Ngrams data set,to build the language model that scores candidate words by context
- Semantic knowledge: word2vec, Paraphrase Database, WordNet 3.0
- Phonetic data: The CMU pronouncing dictionary
You can access most of the features of the API at the URL api.datamuse.com/words, with the query parameters described below.
Query parameters | Example | Result |
---|---|---|
rel_jjb | Adjectives that are often used to describe ocean | /words?rel_jjb=ocean |
topics | Adjectives describing ocean sorted by how related they are to temperature | /words?rel_jjb=ocean&topics=temperature |
rel_jja | Nouns that are often described by the adjective yellow | /words?rel_jja=yellow |
rel_bga | Frequent followers of hope | /words?rel_bga=hope |
ml | Words with a meaning similar to perished | /words?ml=perished |
rel_trg | "Triggers" (words that are statistically associated with pain in the same piece of text.) | /words?rel_trg=pain |
rel_ant | Antonyms of loud) | /words?rel_ant=loud |
sp | Words that start with t, end in k, and have two letters in between | /words?sp=t??k |
Type | Rules |
---|---|
Plant | Nouns(ml) <-> Adjectives(ml) |
Dandelion | Triggers of word in context |
Ginkgo | Adjectives that are often used to describe context + word |
Ivy | A sequence of Frequent followers(rel_bga) |
Pine | A list of words that start and end with the same letters as word in context |
Bamboo | A sequence of words that ends with the first letter of the previous word in context |
Willow | A list of words that rythm with the given word |
Check here to play with Seedlings_.(Best Viewed in Chrome)
"D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS." It is a great tool to create beautiful, interactive, browser-based data visualizations.
SVG
- SVG stands for Scalable Vector Graphics
- It is used to define graphics for the Web. It is not a direct image, but a way to create images following instructions. As its name suggests, it scales itself according to the size of the browser, so resizing your browser will not distort the image. All browsers support SVG except IE 8 and below. D3.js provides convenient tools to manipulate SVG.
- Difference between Canvas and SVG: Canvas is pixel-oriented. Once the pixels hit the screen, you cannot change shapes except by overwriting them with other pixels. However, SVG is like a "draw" program, its graphical elements become part of the DOM. Any part of any shape can be changed through script and CSS.
In d3Example you can find an interactive visualization of adjective/noun relationships in English. It was made using the "rel_jjb" and "rel_jja" queries in datamuse API, and the D3 force layout.
Modify the code to create your own linguistic plant!
Beautiful intro to python documentation by Sam Lavigne
Open terminal on MacOS, and type in the following and hit enter.
python -V
We are using python3 in this case
pip is a tool to install python library. If you are on MacOS, open terminal, using command line:
sudo easy_install pip
You will be asked for your mac password, type it and hit enter. You can also follow the install guide here.
virtualenv creates isolated python environments tied to specific projects. f
sudo pip install virtualenv
Create a new project folder "your_project_name", and cd(change directory) to this folder on terminal.
In terminal, type in the following to create a virtual environment for this project and activate it
virtualenv env
source env/bin/activate
You should see (env) at the front of the current line in terminal.
- datamuse, nltk, flask
pip3 install -r requirements.txt
To see demo from all plant types:
python plant.py demo
An example of a generative chain:
python plant.py test
Plant specific seedlings with the following syntax: "plant --word(noun or adjective) in --domain as --plantType"
python plant.py soft in postmodernism as plant
FLASK_APP=plant_server.py flask run