def getSummary(self, summ, baseUrl): summ_text = summ anchorDict = getAnchors() anchorDictionary = dict() anchorDictionary = anchorDict.getAllLinks(baseUrl) all_words=[] dict_words=[] word_tokenized = word_tokenize(summ_text) for i in word_tokenized: all_words.append(i) for v in anchorDictionary.values(): dict_words.append(v) i=0 key_name_dict=dict() for w in dict_words: if w in summ_text: key = "key" + str(i) key_name_dict[key] = w summ_text=summ_text.replace(w,key) i = i + 1 return summ_text,key_name_dict,anchorDictionary
#shift link program from sampleAnchors import getAnchors from nltk import * import re import speech import urllib2 summ_text = "We live in a country called India. London is a five hour flight from here. It borders Ukraine. There are many universities which are\ good in the world. Northwestern University is one of them" anchorDict = getAnchors() anchorDictionary = dict() anchorDictionary = anchorDict.getAllLinks() #print anchorDictionary all_words=[] dict_words=[] word_tokenized = word_tokenize(summ_text) #print word_tokenized for i in word_tokenized: all_words.append(i) for v in anchorDictionary.values(): dict_words.append(v)