![screenshot][]
In the following we will be using R’s “restarts” feature to implement the state machine that drives generators in languages such as Python. Generators allow lazily generating values on demand: a consumer invokes a generator, and consumes values as they are produced. A new value is only produced once the previous one has been consumed.
#!/usr/bin/env python | |
""" | |
Twitter's API doesn't allow you to get replies to a particular tweet. Strange | |
but true. But you can use Twitter's Search API to search for tweets that are | |
directed at a particular user, and then search through the results to see if | |
any are replies to a given tweet. You probably are also interested in the | |
replies to any replies as well, so the process is recursive. The big caveat | |
here is that the search API only returns results for the last 7 days. So |
This experiment converts an SQL version of WordNet 3.0 into a graph, using the python library graph-tool. In order to create a taxonomical structure, only noun synsets, hyponym links and hypernym links are considered.
The result of the conversion is saved as GraphML, then rendered as the following hairball:
Since the graph can be considered a tangled tree, i.e. a tree in which some nodes have multiple parents, two untangled versions (using longest and shortest paths) are also provided as GraphML. Only a few links are lost (about 2%), making the tree a good approximation of the noun taxonomy graph.