Esempio n. 1
0
from pickle_file_loader_for_ads import PickleFileLoaderForAds
from pickle_file_saver_for_ads import PickleFileSaverForAds
from term_counter import TermCounter
import constants
from query import Query
import pdb

if __name__ == '__main__':
    pfl = PickleFileLoaderForAds()
    queries = ['野球 が 上手くなる']
    for query in queries:
        adding_terms = []
        ads = pfl.load_ads_with_query(query)
        sahens = []
        for ad in ads:
            ad.set_sahens_from_title_and_snippet()
            sahens.extend(ad.sahens)
        counter = TermCounter()
        counter.count_terms(sahens)
        frequent_terms = counter.frequent_terms()
        for term in frequent_terms:
            if term in query:
                continue
            adding_terms.append(term)

        q = Query(query)
        q.set_expansion_words(adding_terms)
        pfs = PickleFileSaverForAds()
        pfs.save_query(q)
from pickle_file_loader_for_ads import PickleFileLoaderForAds
from pickle_file_saver_for_ads import PickleFileSaverForAds
from term_counter import TermCounter
import constants
from query import Query
import pdb

if __name__ == "__main__":
    pfl = PickleFileLoaderForAds()
    queries = ["野球 が 上手くなる"]
    for query in queries:
        adding_terms = []
        ads = pfl.load_ads_with_query(query)
        sahens = []
        for ad in ads:
            ad.set_sahens_from_title_and_snippet()
            sahens.extend(ad.sahens)
        counter = TermCounter()
        counter.count_terms(sahens)
        frequent_terms = counter.frequent_terms()
        for term in frequent_terms:
            if term in query:
                continue
            adding_terms.append(term)

        q = Query(query)
        q.set_expansion_words(adding_terms)
        pfs = PickleFileSaverForAds()
        pfs.save_query(q)
Esempio n. 3
0
import constants
import time
from ad_fetcher import AdFetcher
from pickle_file_saver_for_ads import PickleFileSaverForAds

if __name__ == '__main__':
    queries = ['野球 が 上手くなる']
    for query in queries:
        ad_fetcher = AdFetcher(query)
        ads = ad_fetcher.fetch_ads()
        pfs = PickleFileSaverForAds()
        pfs.save_ads_with_query(ads=ads, query=query)
        time.sleep(1)
Esempio n. 4
0
# -*- coding: utf-8 -*-
from pickle_file_loader_for_ads import PickleFileLoaderForAds
from pickle_file_saver_for_ads import PickleFileSaverForAds
import pdb
import constants

if __name__ == '__main__':
    pfl = PickleFileLoaderForAds()
    queries = ['野球 が 上手くなる',
               'ビリヤード が 上手くなる',
               'サッカー が 上手くなる',
               'ハンドボール が 上手くなる']
    for query in queries:
        expanded_queries = pfl.load_expanded_queries_with_query(query)
        pfs = PickleFileSaverForAds()
        for expanded_query in expanded_queries:
            # query.body => '部屋 借りる', #query.expansion_words => ['家賃', '比較']
            print('%sをsearchします!' % expanded_query.body)
            pages = expanded_query.search_with_expansion_words()
            pfs.save_pages_with_query(pages_dict=pages,
                                      original_query=expanded_query.body)
            print('%sで検索して、その結果を保存しました!' % expanded_query.expansion_words)