本文整理汇总了Python中searcher.Searcher类的典型用法代码示例。如果您正苦于以下问题:Python Searcher类的具体用法?Python Searcher怎么用?Python Searcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Searcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
def search():
global index
query = request.args.get('q')
doc_set = request.args.get('d')
doc_set_names = DocSet(index_directory).get_doc_set_names()
if query:
if doc_set != 'all':
actual_query = u"text:%s doc_set:%s" % (
query, doc_set)
else:
actual_query = query
searcher = Searcher(index)
results = searcher.find_by_full_text(actual_query)
if results:
message = None
else:
message = 'No documents found.'
return render_template("index.html",
results = results,
message = message,
query = query,
selected_doc_set = doc_set,
doc_set_names = doc_set_names)
else:
return render_template("index.html",
doc_set_names = doc_set_names)
示例2: search
def search(request, search=None, cats=None, scats=None):
page_number = request.GET.get('page', 1)
searcher = Searcher(search, cats, scats)
snps = Post.objects.order_by('-posted')
snps = searcher.filter_queryset(snps)
searcher.unfilter_categories()
selector = QuerySelector(snps, dict(
download=DownloadNzbAction(),
))
if request.method == 'POST':
action_response = selector.apply_action(request)
if isinstance(action_response, HttpResponse):
return action_response
paginator = Paginator(
selector,
settings.POST_PER_PAGE,
allow_empty_first_page=True,
orphans=0,
)
if page_number == "last":
page = paginator.page(paginator.num_pages)
else:
try:
page = paginator.page(page_number)
except InvalidPage, EmptyPage:
raise Http404
示例3: search
def search(self, query):
"""
Search in the index for answer to query and return a list of relevant
urls.
"""
self._logger.info('query: ' + query)
searcher = Searcher()
return searcher.query(query)
示例4: scrape
def scrape(self):
self.scrape_results = defaultdict(lambda: defaultdict(list))
for category_of_document_path in self.qd_dict:
for file in self.qd_dict[category_of_document_path]:
s = Searcher(category_of_document_path, file, self.qd_dict)
s.search()
self.scrape_results[os.path.split(category_of_document_path)[1]][os.path.splitext(file)[0]] = s.results
print len(self.scrape_results)
示例5: find_torrent
def find_torrent(self):
print 'Start capturing torrent'
searcher = Searcher(self.driver)
items = []
while(True):
searcher.find_torrents(items)
time.sleep(60)
self.driver.refresh()
示例6: SearcherTests
class SearcherTests(unittest.TestCase):
def setUp(self):
self.alist = [2,3,4,5,6,11,25]
self.searcher = Searcher()
def test_binarySearch(self):
self.assertEqual(True, self.searcher.binary_search(self.alist, 2))
self.assertEqual(True, self.searcher.binary_search(self.alist, 25))
self.assertEqual(True, self.searcher.binary_search(self.alist, 5))
self.assertEqual(False, self.searcher.binary_search(self.alist, 7))
self.assertEqual(False, self.searcher.binary_search(self.alist, 26))
示例7: main
def main():
searcher = Searcher("data.json")
while True:
print
response = "n"
print "=================================="
while response != "y":
response = raw_input("Ready to say something? (y/n)")
q, filters = query_speech()
if not q:
continue
print "Filters:"
print filters
print searcher.process_query(q, filters)
示例8: search
def search(keywords):
keyword_list = keywords.split(" ")
collector = Collector()
if collector.is_meiju_info_file_exist():
collector.read_all_meiju_info_from_file()
else:
collector.save_all_meiju_info()
collector.write_all_meiju_info_to_file()
searcher = Searcher()
meiju_ename_list = searcher.search_meiju_list_by_english_name_keyword(collector, keyword_list)
click.echo("Total %d Meiju is found. Following are the lists:" % len(meiju_ename_list))
for meiju_ename in meiju_ename_list:
click.echo("%s" % meiju_ename)
return
示例9: Match
def Match(queryname,k):
folder="static"
queryImage = cv2.imread(os.path.join(folder,queryname))
desc = RGBHistogram([8, 8, 8])
# load the index perform the search
#index = cPickle.loads(open("index.txt").read())
d = min(division(queryImage),7)
folder='indexIMG'
index = shelve.open(os.path.join(folder,'f%d.shelve'%d))
searcher = Searcher(index)
queryFeatures = desc.describe(queryImage)
results = searcher.search(queryFeatures)
l=len(results)
lastRes=results[:min(k,l)]
return lastRes
示例10: __init__
def __init__(self, parent = None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.setWindowTitle("Search My Workspace")
# List to display search results
self.searchResultsModel = SearchResultsModel()
self.listView_result.setModel(self.searchResultsModel)
searchResultsDelegate = SearchResultsDelegate(self.listView_result)
self.listView_result.setItemDelegate(searchResultsDelegate);
# Tree to display facets
self.facetModel = FacetModel()
self.treeView_facet.setModel(self.facetModel)
self.facetModel.modelReset.connect(self.treeView_facet.expandAll)
# searcher
self.searcher = Searcher()
self.searcher.searchDone.connect(self.searchDone)
# signal slots
self.createConnections()
示例11: search
def search(img):
# initialize the image descriptor
cd = ColorDescriptor((8, 12, 3))
# load the query image and describe it
#query = cv2.imread(args["query"])
#query = cv2.imread("queries/2.png")
features = cd.describe(img)
# perform the search
searcher = Searcher("feature.csv")
results = searcher.search(features)
return results
示例12: __init__
def __init__(self, access_course, access_note, access_user, access_enrollment):
""" to initialize a submit note instance """
self.access_course = access_course
self.access_note = access_note
self.access_user = access_user
self.access_enrollment = access_enrollment
self.searcher = Searcher(self.access_course, self.access_note, self.access_user)
self.userControl = userControl = UserControl(self.access_user, self.access_enrollment)
示例13: setUp
def setUp(self):
"""
Setup search engine that will be subjected to the tests.
"""
self.twitter = Twitter(CUR_DIR + "/test_crossfit.tweets", CUR_DIR + "/test_stop_words.txt")
self.twitter.load_tweets_and_build_index()
self.searcher = Searcher(self.twitter.tweets, self.twitter.stop_words)
示例14: SearcherTests
class SearcherTests(unittest.TestCase):
"""
Test case for SearchEngine class.
"""
def setUp(self):
"""
Setup search engine that will be subjected to the tests.
"""
self.twitter = Twitter(CUR_DIR + "/test_crossfit.tweets", CUR_DIR + "/test_stop_words.txt")
self.twitter.load_tweets_and_build_index()
self.searcher = Searcher(self.twitter.tweets, self.twitter.stop_words)
def test_indexed_doc_count(self):
self.assertEqual(self.searcher.count(), 10)
def test_existent_term_search(self):
"""
Test if search is correctly performed.
"""
results = self.searcher.search("coach")
expected_results = 3
self.assertEqual(results[0].indexable.docid, expected_results)
def test_non_existent_term_search(self):
"""
Test if search is correctly performed.
"""
expected_results = []
results = self.searcher.search("asdasdasdas")
self.assertListEqual(results, expected_results)
def test_search_result_limit(self):
"""
Test if search results can be limited.
"""
results = self.searcher.search("crossfit", 1)
expected_results = 6
self.assertEqual(results[0].indexable.docid, expected_results)
示例15: load
def load(self):
if os.path.exists(self.file_path):
f = open(self.file_path, "r")
conn_map = pickle.load(f)
f.close()
return conn_map
conn_maps = {}
for name, conn in self.connections.items():
conn_map = {}
searcher = Searcher(conn)
searcher.search()
conn_map["tables"] = searcher.tables
conn_map["connection"] = searcher.connection
conn_maps[name] = conn_map
f = open(self.file_path, "w")
pickle.dump(conn_maps, f)
f.close()
return conn_maps