- Knowledge Bases (KBs) are effective tools for Question Answering (QA) but are often too restrictive (due to fixed schema) and too sparse (due to limitations of Information Extraction (IE) systems).
- The paper proposes Key-Value Memory Networks, a neural network architecture based on Memory Networks that can leverage both KBs and raw data for QA.
- The paper also introduces MOVIEQA, a new QA dataset that can be answered by a perfect KB, by Wikipedia pages and by an imperfect KB obtained using IE techniques thereby allowing a comparison between systems using any of the three sources.
- Link to the paper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
$ uname -r
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Find your tweets from this date in earlier years. | |
| # OS X's date function doesn't have the required date math capabilities. | |
| # This requires GNU date. You can get it on OS X with `brew install coreutils` | |
| GDATE=/usr/local/bin/gdate | |
| USERNAME=realDonaldTrump | |
| export URL="https://twitter.com/search?q=from%3A$USERNAME%20(" | |
| for yearsago in {1..12}; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| from dateutil.relativedelta import relativedelta | |
| def today(date=None,iso=False): | |
| if date is None: date=datetime.date.today() | |
| if iso: return date.isoformat() | |
| else: return date | |
| def yesterday(date=None,iso=False): | |
| if date is None: date=today() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| how to count as fast as possible | |
| (numbers from Python 3.5.2 on a Macbook Pro) | |
| YMMV, but these results are pretty stable for me, say +/- 0.1s on repeated runs | |
| """ | |
| from collections import Counter, defaultdict | |
| import random | |
| random_numbers = [random.randrange(10000) for _ in range(10000000)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import six | |
| import os | |
| if six.PY3: | |
| from urllib.request import urlopen | |
| else: | |
| from urllib2 import urlopen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"comment": "Kaiserslautern ([\u02ccka\u026az\u0250s\u02c8la\u028at\u0250n]) is a city in southwest Germany, located in the Bundesland (State) of Rhineland-Palatinate (Rheinland-Pfalz) at the edge of the Palatinate Forest (Pf\u00e4lzerwald). The historic centre dates to the 9th century. It is 459 kilometres (285 miles) from Paris, 117 km (73 miles) from Frankfurt am Main, and 159 km (99 miles) from Luxembourg.", "pic": "http://commons.wikimedia.org/wiki/Special:FilePath/Kaiserslautern-Stadtwappen.svg", "uri": "http://dbpedia.org/resource/Kaiserslautern", "label": "Kaiserslautern", "areaTotal": "1.3972e+08", "types": ["http://www.w3.org/2002/07/owl#Thing", "http://www.wikidata.org/entity/Q3957", "http://www.wikidata.org/entity/Q486972", "http://dbpedia.org/ontology/PopulatedPlace", "http://dbpedia.org/ontology/Settlement", "http://dbpedia.org/ontology/Town", "http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing", "http://schema.org/Place", "http://dbpedia.org/ontology/Place", "http://dbpedia.org/ontology/Locat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import requests | |
| from io import BytesIO, SEEK_SET, SEEK_END | |
| class ResponseStream(object): | |
| def __init__(self, request_iterator): | |
| self._bytes = BytesIO() | |
| self._iterator = request_iterator |
Some jq examples translated from https://github.com/jsonlines/guide
jq can be downloaded from https://stedolan.github.io/jq/download/.
curl https://raw.githubusercontent.com/jsonlines/guide/master/datagov100.json > data.json$ < data.json jq '.name' | head -n 6