def __init__(self, name, makeString=True, wordVec=True, senna=True): if name.isdigit(): self.name = name self.googleURL = name else: self.name = name self.googleURL = data.getGoogleURL(self) if makeString: self.string = data.getGoogleCase(self) tokenizer = linguistics.getTokenizer() self.tokens = tokenizer.tokenize(self.string) self.tokenSummary = {1:[], 2:[], 3:[], 4:[]} learning.readLabels([self], 'tokens') #if wordVec: # self.representation = wordVector.getRepresentation(self) if senna: self.sennaMatrix = linguistics.getSennaMatrix(self) self.sentences = linguistics.getSennaAlignedSentences(self) self.srlSentences = linguistics.getSrlSentences(self) self.indicators = linguistics.resolveAnaphora(self) self.srlSummary = {1:[], 2:[], 3:[], 4:[]} learning.readLabels([self], 'srl')
if 'V' in clause and clause['V'] == word: polyfitInput[0] += 1 for clause in dm: if 'A0' in clause and clause['A0'] == word: polyfitInput[1] += 1 if 'V' in clause and clause['V'] == word: polyfitInput[1] += 1 print polyfitInput model[i] = np.polyfit([1, m], polyfitInput, 1) print model return findShortChains() if __name__ == "__main__": cases = data.getAllSavedCases() labeledTraining = learning.findLabels(cases) learning.readLabels(labeledTraining) unlabeledCases = filter(lambda x:x not in labeledTraining, cases) unlabeledTraining = unlabeledCases[:-1] testing = [unlabeledCases[-1]] learning.labelCases(labeledTraining, unlabeledTraining, testing, numIterations=20) for cas in testing: print 'case ' + str(cas.name) d = {} for person, summarySentences in cas.summary.iteritems(): personSentences = [] for sentence in summarySentences: personSentences.append(cas.sentences[sentence]) d[person] = personSentences for person, summarySentences in d.iteritems(): print coherentSummary(summarySentences, cas.sentences, cas.srlSentences)
for clause in dm: if 'A0' in clause and clause['A0'] == word: polyfitInput[1] += 1 if 'V' in clause and clause['V'] == word: polyfitInput[1] += 1 print polyfitInput model[i] = np.polyfit([1, m], polyfitInput, 1) print model return findShortChains() if __name__ == "__main__": cases = data.getAllSavedCases() labeledTraining = learning.findLabels(cases) learning.readLabels(labeledTraining) unlabeledCases = filter(lambda x: x not in labeledTraining, cases) unlabeledTraining = unlabeledCases[:-1] testing = [unlabeledCases[-1]] learning.labelCases(labeledTraining, unlabeledTraining, testing, numIterations=20) for cas in testing: print 'case ' + str(cas.name) d = {} for person, summarySentences in cas.summary.iteritems(): personSentences = [] for sentence in summarySentences: personSentences.append(cas.sentences[sentence]) d[person] = personSentences