Last active
December 20, 2015 18:59
-
-
Save markhamilton/6180240 to your computer and use it in GitHub Desktop.
Make assertions between two ConceptNet concepts using python at the command line.
This file contains 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
#!/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