Exemplo n.º 1
0
def with_patterns_to_pages(query, word):
    # ""で厳密なマッチャで検索する。
    # word => "で", "に" など
    pm = PatternMatcher('"' + word + query + '"')
    pages = pm.bing_search()
    for page in pages:
        page.build_keyword(word + query)
        page.pattern_word = word
        page.query = query
    # page.keywordが''だったら最後に返すpageに入れない
    return [page for page in pages if page.keyword]
Exemplo n.º 2
0
                                             constants.ACTION_WORD_IN_QUERY)
        except (ValueError, IndexError):
            continue
        if keyword:
            keywords.add(keyword)
    print(keywords)

    # 〜〜を使う、の〜〜も最終結果に入れる
    results_dic = {}
    for keyword in keywords:
        results_dic[keyword] = set()

    for keyword in keywords:
        pm = PatternMatcher(constants.QUERY + ' "' + constants.SO_CALLED +
                            keyword + '"')
        keyword_pages = pm.bing_search()
        for page in keyword_pages:
            try:
                result = page.noun_before_query(page.snippet,
                                                constants.SO_CALLED + keyword)
            except (ValueError, IndexError):
                continue
            if result:
                # results_dic[keyword] => set()からset(['アレロック', 'アルガード'])
                results_dic[keyword].add(result)

    with open(constants.PICKLE_RESULT_DICT_NAME, 'wb') as f:
        pickle.dump(results_dic, f)

    pdb.set_trace()
Exemplo n.º 3
0
def search_web_pages(query):
    pm = PatternMatcher(query)
    pages = pm.bing_search()
    return pages
Exemplo n.º 4
0
def search_web_pages(query):
    pm = PatternMatcher(query)
    pages = pm.bing_search()
    return pages
    for page in pages:
        try:
            keyword = page.noun_before_query(page.snippet, constants.ACTION_WORD_IN_QUERY)
        except (ValueError, IndexError):
            continue
        if keyword:
            keywords.add(keyword)
    print(keywords)

    # 〜〜を使う、の〜〜も最終結果に入れる
    results_dic = {}
    for keyword in keywords:
        results_dic[keyword] = set()

    for keyword in keywords:
        pm = PatternMatcher(constants.QUERY + ' "' + constants.SO_CALLED + keyword + '"')
        keyword_pages = pm.bing_search()
        for page in keyword_pages:
            try:
                result = page.noun_before_query(page.snippet, constants.SO_CALLED + keyword)
            except (ValueError, IndexError):
                continue
            if result:
                # results_dic[keyword] => set()からset(['アレロック', 'アルガード'])
                results_dic[keyword].add(result)

    with open(constants.PICKLE_RESULT_DICT_NAME, 'wb') as f:
        pickle.dump(results_dic, f)

    pdb.set_trace()