Beispiel #1
0
	def search(self, query, lang, stem = True):
		normQuery = remove_nonletters(query, ' ', ['(', ')'])
		parsedQuery, terms, wordsTerms = self._parse_query(normQuery, stem, lang)
		documents = self.index.get_documents(parsedQuery)
		rankedResults = score(terms, documents, self.index, lang)
		sortedResults = sorted(rankedResults, key=lambda doc: doc['score'], reverse=True)
		return {'documents':sortedResults, 'terms':terms, 
				'pureQuery':query, 'parsedQuery':parsedQuery, 'wordsTerms':wordsTerms}
Beispiel #2
0
 def search(self, query, lang, stem=True):
     normQuery = remove_nonletters(query, ' ', ['(', ')'])
     parsedQuery, terms, wordsTerms = self._parse_query(
         normQuery, stem, lang)
     documents = self.index.get_documents(parsedQuery)
     rankedResults = score(terms, documents, self.index, lang)
     sortedResults = sorted(rankedResults,
                            key=lambda doc: doc['score'],
                            reverse=True)
     return {
         'documents': sortedResults,
         'terms': terms,
         'pureQuery': query,
         'parsedQuery': parsedQuery,
         'wordsTerms': wordsTerms
     }
Beispiel #3
0
	def test_remove_nonletters(self):
		self.assertEqual('helloworld', remove_nonletters('hello__world!!! :-)) <3 :-|'))
		self.assertEqual('hello  world   ', remove_nonletters('hello__world!?!', ' '))
Beispiel #4
0
 def test_remove_nonletters(self):
     self.assertEqual('helloworld',
                      remove_nonletters('hello__world!!! :-)) <3 :-|'))
     self.assertEqual('hello  world   ',
                      remove_nonletters('hello__world!?!', ' '))