Ejemplo n.º 1
0
	def _get_json_resp(self, corpus=None, word=None):
		corpusname = corpus
		if not corpusname or not word:
			return {'ok':False, 'mess':'bad query'}
		corpus = Corpus.load_corpus(corpusname)
		count, relfreq = corpus.find_word(word)
		return {'ok':True, 'count':count, 'relfreq':relfreq}
Ejemplo n.º 2
0
	def GET(self):
		if not web.input().get('word'):
			err_mess = '<html><head><title>No Input Value</title></head>'
			err_mess+='<body>You must provide the word to be searched.</body></html>'
			return err_mess
		word = web.input().word
		table = []
		for name in Corpus.names:
			corpus = Corpus.load_corpus(name)
			count, relfreq = corpus.find_word(word)
			tup = (corpus.fullname, count, '%1.4f%%' % (relfreq*100))
			table.append(tup)
		if session.get('data'):
			f = open(STATIC_PATH+session['data'])
			count, relfreq = search_user_corpus(f, word)
			tup = ("Your Writing", count, '%1.4f%%' % (relfreq*100))
			table.append(tup)
		return render.comparison(word=word, table=table)