Skip to content

Instantly share code, notes, and snippets.

@markhamilton
Last active December 20, 2015 18:59
Show Gist options
  • Save markhamilton/6180240 to your computer and use it in GitHub Desktop.
Save markhamilton/6180240 to your computer and use it in GitHub Desktop.
Make assertions between two ConceptNet concepts using python at the command line.
#!/bin/env python
"""
Usage:
chmod +x assert.py
./assert.py <concept1> <concept2>
You will need to tweak the parameters indices if you are in Windows.
Original code by MIT, modifications by Mark Hamilton.
"""
import sys
from conceptnet.models import *
if len(sys.argv) != 3:
print "You need to provide two concepts"
exit()
raw = []
assertions = Assertion.objects.filter(concept1__text = sys.argv[1], concept2__text = sys.argv[2], language=en)
for a in assertions:
raw.extend(a.rawassertion_set.all())
for r in raw:
print r.nl_repr()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment