Esempio n. 1
0
def get_similar_concepts(concepts,filter='/c/en/',limit=10,**kwargs):
    """
    Returns a dict of results for each concept.
    """
    #build urls dict
    urls={}
    for concept in concepts:
        urls[concept]=association_url(concept,filter,limit,**kwargs)
    return co.requests(urls,parsing_method=parse_similar_concepts)
Esempio n. 2
0
def search_concepts(concepts,filter='/c/en/',limit=10,**kwargs):
    """
    Returns a dict of search results for each concept.
    """
    #build urls dict
    urls={}
    for concept in concepts:
        urls[concept]=lookup_url(concept,filter,limit,**kwargs)
    return co.requests(urls,parsing_method=parse_relevant_edges)
Esempio n. 3
0
def search_edges_from(concepts,filter='/c/en/',limit=10,**kwargs):
    """
    Returns a dict of results for each concept.
    In kwargs we expect for example a minWeight
    """
    #build urls dict
    urls={}
    for concept in concepts:
        concept = concept.replace(' ', '_')
        urls[concept]=search_url(start='/c/'+settings.LANGUAGE+'/'+concept,filter=filter,limit=limit,**kwargs)
    return co.requests(urls,parsing_method=parse_relevant_edges)
Esempio n. 4
0
def search_concepts(concepts, filter='/c/en/', limit=10, **kwargs):
    '''
    Performs lookup queries and parses results into edges objects.
    @see result.py

    @param concepts  Iterable of concepts, words or small phrases.
    @param limit    The number of results needed for each query.
    @param kwargs Other supported lookup arguments, for each query.
    @return A dict which contains, for each concept, a list of result.Edge objects.
    '''
    urls = {}
    for concept in concepts:
        urls[concept] = lookup_url(concept, filter, limit, **kwargs)
    return co.requests(urls, parsing_method=parse_relevant_edges)
Esempio n. 5
0
def get_similar_concepts(concepts, filter='/c/en/', limit=10, **kwargs):
    """
    Performs associations query and parses the results.

    @param concepts Iterable of word or small phrases.
    @param filter Filter.
    @param limit Maximum number of results.
    @param kwargs Other supported association arguments.
    @return A dict which contains, for each concept, a list of [concept,similarity].
    """
    urls = {}
    # we build a dict of url
    for concept in concepts:
        urls[concept] = association_url(concept, filter, limit, **kwargs)
    return co.requests(urls, parsing_method=parse_similar_concepts)
Esempio n. 6
0
def search_edges_from(concepts, filter='/c/en/', limit=10, **kwargs):
    """
    Performs search queries with start=concept for each concept in concepts.

    @param concepts Iterable of concepts (word or small phrase) .
    @param filter Filter.
    @param limit Maximum number of results.
    @param kwargs Other supported search arguments.
    @return A dict which contains, for each concept, a list of result.Edge objects.
    """
    # build urls dict
    urls = {}
    for concept in concepts:
        concept = concept.replace(' ', '_')
        urls[concept] = search_url(start='/c/' + settings.LANGUAGE + '/' +
                                   concept,
                                   filter=filter,
                                   limit=limit,
                                   **kwargs)
    return co.requests(urls, parsing_method=parse_relevant_edges)
Esempio n. 7
0
def search_names(names,**kwargs):
	urls={}
	for name in names:
		urls[name]=search_name_url(name.replace(' ', '_'),**kwargs)
	return co.requests(urls,parsing_method=parse_results)