本文整理匯總了Python中search.search方法的典型用法代碼示例。如果您正苦於以下問題:Python search.search方法的具體用法?Python search.search怎麽用?Python search.search使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類search
的用法示例。
在下文中一共展示了search.search方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: extend
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def extend(self):
profile = self.profile
res = search.search(profile.bestname(),['twitter.com','facebook.com','plus.google.com','linkedin.com'],True)
for r in res:
wp = WebProfiler.fromURL(r)
if wp:
resultprofile = wp.getProfile()
if resolver.areEquivalent(resultprofile,profile):
#merge the mined fields.
profile.names = list(set(profile.names+resultprofile.names))
profile.education = list(set(profile.education+resultprofile.education))
profile.location_set = list(set(profile.location_set+resultprofile.location_set))
profile.email_addresses = list(set(profile.email_addresses+resultprofile.email_addresses))
profile.phone_numbers = list(set(profile.phone_numbers+resultprofile.phone_numbers))
profile.grouped = list(set(profile.grouped+resultprofile.grouped))
profile.web_links = list(set(profile.web_links+resultprofile.web_links+[r]))
profile.profile_links = list(set(profile.profile_links+resultprofile.profile_links))
self.profile = profile
return self.profile
示例2: search
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def search(self, query, attributes=['name', 'description'], limit=10):
return search.search(query, attributes, Item.select(), limit)
示例3: test_search_tavolo_sedie
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_tavolo_sedie(self):
result = self.search('tavolo sedie')
res = ['tavolo con sedie', 'tavolo con set di sedie', 'tavolo da cucina',
'tavolino', 'tavola di legno', 'sedie', 'set di sedie', 'tavolo', 'tavola']
assert res == get_names(result)
示例4: test_search_tavolo
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_tavolo(self):
result = self.search('tavolo')
res = ['tavolo', 'tavolino', 'tavola', 'tavola di legno', 'legno di tavola',
'tavolo con sedie', 'tavolo con set di sedie', 'tavolo da cucina', 'poltrona',
'letto singolo']
assert res == get_names(result)
示例5: test_search_sedia
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_sedia(self):
result = self.search('sedia')
res = ['sedie', 'set di sedie', 'sedie da cucina', 'sedie deco',
'divano', 'tavolo con sedie', 'tavolo con set di sedie', 'divano letto']
assert res == get_names(result)
示例6: test_search_sedie
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_sedie(self):
result = self.search('sedie')
res = ['sedie', 'set di sedie', 'sedie deco', 'sedie da cucina',
'tavolo con sedie', 'tavolo con set di sedie', 'scarpine']
assert res == get_names(result)
示例7: test_search_letto
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_letto(self):
result = self.search('letto')
res = ['letto', 'letto matrimoniale', 'divano letto', 'letto singolo', 'letto francese',
'tavola di legno', 'legno di tavola', 'poltrona elettrica', 'sedie deco', 'tavolo']
assert res == get_names(result)
示例8: test_search_scarpette
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_scarpette(self):
result = self.search('scarpette')
res = ['scarpette', 'scarpe', 'scarpine', 'scarpacce', 'scarponi',
'scarpe da ginnastica', 'scarpe da ballo', 'maglietta', 'canottiera',
'letto francese']
assert res == get_names(result)
示例9: test_search_scarponi
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_scarponi(self):
result = self.search('scarponi')
res = ['scarponi', 'scarpine', 'scarpe', 'scarpette',
'scarpacce', 'scarpe da ballo', 'scarpe da ginnastica']
assert res == get_names(result)
示例10: test_search_divano
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def test_search_divano(self):
result = self.search('divano')
res = ['divano', 'divano letto']
assert res == get_names(result)
示例11: search2
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def search2(request):
params = json.loads(request.body)
return search.search(params)
# Get distinct values in schema
示例12: fromPerson
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def fromPerson(person):
approved = None
for profile in person.profiles:
res = search.search(profile.bestname(),['twitter.com','facebook.com','plus.google.com','linkedin.com'],True)
for r in res:
wp = WebProfiler.fromURL(r)
if wp:
resultprofile = wp.getProfile()
if resultprofile and resolver.areEquivalent(resultprofile,profile):
approved = resultprofile
break
return approved
示例13: main
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def main(c,t='????',p=2):
sh =search(c)
lt =sh.search(t,p)
setWeiboMongo(lt)
rst=getOneWeibo()
if rst is False:
print('No more weibo to retweet!')
return False
rt=retweet(c)
state=rt.retweet(rst['mid'],rst['reason'])
if state:
return rst
return False
示例14: search
# 需要導入模塊: import search [as 別名]
# 或者: from search import search [as 別名]
def search(cls, query, dataset, limit=-1,
attributes=None, weights=None,
threshold=search.config.THRESHOLD):
"""
Search a list of resources with the callee class.
Arguments:
query (str): Query to lookup for
dataset (iterable): sequence of resource objects to lookup into
limit (int): maximum number of resources to return (default -1, all)
attributes (list): model attribute names. Can be set as default
inside the model definition or specified on the fly while
searching.
weights (list): attributes weights values,indexes should
match the attribute position in the `attributes` argument.
if length does not match it will be ignored.
threshold (float): value between 0 and 1, identify the matching
threshold for a result to be included.
Returns:
list: list of resources that may match the query.
Raises:
SearchAttributeMismatch:
if ``attributes`` are missing, either as model
default in ``<Model>._search_attributes`` or as param
one of the object does not have one of the given attribute(s).
Examples:
.. code-block:: python
results = Item.search('shoes', Item.select(), limit=20)
"""
attributes = attributes or cls._search_attributes
weights = weights or cls._search_weights
if not attributes:
raise SearchAttributeMismatch(
'Attributes to look for not defined for {}. \
Please update the Model or specify during search call.\
'.format(cls.__name__))
return search.search(query, attributes, dataset, limit, threshold, weights)