示例#1
0
def index():
    query = request.args.get('q')
    if not query:
        return render_template("index.html")
    else:

        lemmatised_query = lemmatiseQuery(query)
        pears = findBestPears.runScript(lemmatised_query)
        pear_names = []
        for p in pears:
            pear_names.append(p[0])
            print p
        pages = scorePages.runScript(pear_names, lemmatised_query)
        if len(pears) == 0:
            pears = [[
                'nopear', 'Sorry... no pears found :(', './static/pi-pic.png'
            ]]
            print pears

        #'''remove the following lines after testing'''
        #pages = [['http://test.com', 'test']]

        return render_template('results.html',
                               pears=pears,
                               query=query,
                               results=pages)
示例#2
0
    def POST(self):
        form = myform()
        if not form.validates():
            return render.searchform(form)
        else:
            query = form['search'].value
            #print pt.tag(query)
            taggedquery = tagQuery(query)
            #	    print taggedquery
            pears = findBestPears.runScript(taggedquery)
            #	    print "The best pears are: ",pears
            pear_names = []
            for p in pears:
                pear_names.append(p[0])
            pages = scorePages.runScript(pear_names, taggedquery)

            if len(pears) == 0:  #When no results were found...
                pears = [
                    [
                        'nopear', 'Sorry... no pears found :(',
                        './static/pi-pic.png'
                    ]
                ]  #Hack to have something to display in the pears area of results page

            return render.results(pears, pages, query)
示例#3
0
    def POST(self): 
        form = myform() 
        if not form.validates(): 
            return render.searchform(form)
        else:
	    query=form['search'].value
	    #print pt.tag(query)
	    taggedquery=tagQuery(query)
#	    print taggedquery
	    pears=findBestPears.runScript(taggedquery)
#	    print "The best pears are: ",pears
	    pear_names=[]
	    for p in pears:
		pear_names.append(p[0])
	    pages=scorePages.runScript(pear_names,taggedquery)

	    if len(pears) == 0:						#When no results were found...
		pears=[['nopear','Sorry... no pears found :(','./static/pi-pic.png']]				#Hack to have something to display in the pears area of results page

	    return render.results(pears,pages,query)
示例#4
0
文件: views.py 项目: PeARSearch/PeARS
def index():
    query = request.args.get('q')
    if not query:
        return render_template("index.html")
    else:

        lemmatised_query = lemmatiseQuery(query)
        pears = findBestPears.runScript(lemmatised_query)
        pear_names = []
        for p in pears:
            pear_names.append(p[0])
            print p
        pages = scorePages.runScript(pear_names, lemmatised_query)
        if len(pears) == 0:
            pears = [['nopear',
                      'Sorry... no pears found :(',
                      './static/pi-pic.png']]
            print pears

        #'''remove the following lines after testing'''
        #pages = [['http://test.com', 'test']]

        return render_template('results.html', pears=pears,
                               query=query, results=pages)