Permalink
Browse files

Mostly working. Some concepts from inform 6 have a pesky ^ instead of…

… a ' and I can't figure out why
  • Loading branch information...
1 parent 7128c09 commit a447de3e41864b454459dc698684b61f4dacb1e5 @havasi committed May 4, 2011
Showing with 19 additions and 9 deletions.
  1. +4 −4 convertInform.py
  2. +12 −2 endtoend.py
  3. BIN glass.pickle
  4. +3 −3 inform_parser.py
View
@@ -144,8 +144,8 @@ def pullAllTopics(filename):
subjectRegex = makeSubjectRegex()
suggestsRegex = makeSuggestsRegex()
topicList = getEmilyShortTopics(text, subjectRegex, suggestsRegex)
- understandsRegexes = makeBoatloadOfUnderstandsRegexes():
- understandDict = getEmilyShortUnderstands(text, understandsRegexes):
+ understandsRegexes = makeBoatloadOfUnderstandsRegexes()
+ understandDict = getEmilyShortUnderstands(text, understandsRegexes)
topicList.extend(understandDict.keys())
return topicList
@@ -161,8 +161,8 @@ def convertFile(topicDict, understandsDict, filename, newFilename):
for line in file:
text += line
file.close()
- understandsRegexes = makeBoatloadOfUnderstandsRegexes():
- understandDict = getEmilyShortUnderstands(text, understandsRegexes):
+ understandsRegexes = makeBoatloadOfUnderstandsRegexes()
+ understandDict = getEmilyShortUnderstands(text, understandsRegexes)
file = open(newFilename, 'w')
file.write(text + "\n\n" + supplyUnderstandTopics(topicDict,understandDict))
file.close()
View
@@ -2,17 +2,27 @@
#convertFile, pullAllTopics
from otherways import synonyms
import divisi2
+from simplenlp import get_nl
+
+en_nl = get_nl('en')
+
# Davis Square
#topics = pullAllTopics('DavisSquare.txt')
#para = synonyms('davissquare', topics, 0)
#convertFile(para, 'DavisSquare.txt', 'AIwashere.txt')
+topics = pullAllTopics('Glass.txt')
+topics = [en_nl.normalize(x) for x in topics]
+para = synonyms('glass', topics, 0)
+assert False
+
+# Glass - rough
+'''
conceptnet = divisi2.network.conceptnet_matrix('en').normalize_all()
u,s,v = conceptnet.svd()
similarity = divisi2.reconstruct_similarity(u, s) # offset=1.5)
-# Glass
def make_sim_rough(object, topics, n=2):
frame = divisi2.SparseVector.from_counts([object])
sim = similarity.right_category(frame)
@@ -23,5 +33,5 @@ def make_sim_rough(object, topics, n=2):
topics = pullAllTopics('Glass.txt')
for object in topics:
print object
- print make_sim_rough(object, topics)
+ print make_sim_rough(object, topics)'''
View
Binary file not shown.
View
@@ -59,7 +59,7 @@ def name_lister(parse):
def name_assigner(parse):
if currentID:
- idsToNames[currentID].append(parse[2])
+ idsToNames[currentID].append(parse[2].replace('^',"'"))
return []
def id_assigner(parse):
@@ -153,7 +153,7 @@ def inform_parser(filename):
def make_divisi_matrix(filename):
parsedlist = inform_parser(filename)
game = filename.split('.')[0]
- thinglist = [(1 if x[3] else -1, english.normalize(x[0]), ('right', x[1], english.normalize(x[2]))) for x in parsedlist]
+ thinglist = [(1 if x[3] else -1, english.normalize(x[0].replace('^', "'")), ('right', x[1], english.normalize(x[2].replace('^', "'")))) for x in parsedlist]
# Write out the confusingly-named overlist. First, the nouns.
overlist = open(game + '.over', 'w')
for concept1, rel, concept2, val in parsedlist:
@@ -173,4 +173,4 @@ def make_divisi_matrix(filename):
if __name__ == '__main__':
import sys
- matrix = make_divisi_matrix(dict(enumerate(sys.argv)).get(1, 'bronze.inf'))
+ matrix = make_divisi_matrix(dict(enumerate(sys.argv)).get(1, 'glass.inf'))

0 comments on commit a447de3

Please sign in to comment.