Пример #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
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)