Пример #1
0
# -*- coding: utf-8 -*-
import constants
from pickle_file_loader_for_ex import PickleFileLoaderForExpandedQuery
from pickle_file_saver_for_ex import PickleFileSaverForEx
from path_mover import PathMover
import pdb
import os
import constants

if __name__ == '__main__':
    pfl = PickleFileLoaderForExpandedQuery()
    pfs = PickleFileSaverForEx()
    pm = PathMover()

    original_queries = [
        '野球 が 上手くなる', 'ビリヤード が 上手くなる', 'サッカー が 上手くなる', 'ハンドボール が 上手くなる'
    ]

    pm.go_or_create_and_go_to(constants.FETCHED_PAGES_DIR_NAME)
    for original_query in original_queries:
        pm.go_or_create_and_go_to(original_query)
        expanded_queries = os.listdir()
        for expanded_query in expanded_queries:
            if expanded_query == '.DS_Store':
                continue
            pm.go_or_create_and_go_to(expanded_query)
            filenames = os.listdir()
            for i, filename in enumerate(filenames):
                if filename == '.DS_Store':
                    continue
                try:
Пример #2
0
# -*- coding: utf-8 -*-
import pdb
from graph_task_mapper import GraphTaskMapper
from pickle_file_saver_for_ex import PickleFileSaverForEx
from pickle_file_loader_for_ex import PickleFileLoaderForExpandedQuery
import constants

if __name__ == '__main__':
    original_queries = constants.QUERIES_4
    pfs = PickleFileSaverForEx()
    pfl = PickleFileLoaderForExpandedQuery()
    for query in original_queries:
        pages = pfl.load_pages_with_task_with_query(query)
        gtm = GraphTaskMapper()

        for i, page in enumerate(pages):
            try:
                for task in page.tasks:
                    gtm.add_node_and_edge_with_task(task)
                print('%i 番目のページ %s のタスクをグラフに追加しました' % (i, page.title))
            except AttributeError:
                break
        print('added all edges!')
        pfs.save_graph_with_query(obj=gtm.graph, query=query)
Пример #3
0
# -*- coding: utf-8 -*-
import pdb
from graph_task_mapper import GraphTaskMapper
from pickle_file_saver_for_ex import PickleFileSaverForEx
from pickle_file_loader_for_ex import PickleFileLoaderForExpandedQuery
import constants


if __name__ == '__main__':
    original_queries = constants.QUERIES_4
    pfs = PickleFileSaverForEx()
    pfl = PickleFileLoaderForExpandedQuery()
    for query in original_queries:
        pages = pfl.load_pages_with_task_with_query(query)
        gtm = GraphTaskMapper()

        for i, page in enumerate(pages):
            try:
                for task in page.tasks:
                    gtm.add_node_and_edge_with_task(task)
                print('%i 番目のページ %s のタスクをグラフに追加しました' % (i, page.title))
            except AttributeError:
                break
        print('added all edges!')
        pfs.save_graph_with_query(obj=gtm.graph, query=query)
# -*- coding: utf-8 -*-
import pdb
from pickle_file_loader_for_ex import PickleFileLoaderForExpandedQuery
import constants


if __name__ == '__main__':
    original_queries = constants.QUERIES_1
    pfl = PickleFileLoaderForExpandedQuery()
    for query in original_queries:
        pages = pfl.load_fetched_pages_with_query(query)

        for i, page in enumerate(pages):
            try:
                for task in page.tasks:
                    task.insert_task_to_database()
                print('%i 番目のページ %s のタスクをDBに入れました' % (i, page.title))
            except AttributeError:
                break
        print('%sのぶんはおしまい!' % query)
# -*- coding: utf-8 -*-
import pdb
from pickle_file_loader_for_ex import PickleFileLoaderForExpandedQuery

if __name__ == '__main__':
    loader = PickleFileLoaderForExpandedQuery()
    pages = loader.load_pages_with_task_with_query('部屋 掃除する')
    subtype_nouns = {}
    for page in pages:
        for subtype in page.subtypes:
            if not subtype in  subtype_nouns:
                subtype_nouns[subtype] = {'pages': [page]}
            subtype_nouns[subtype]['pages'].append(page)

    for subtype in subtype_nouns:
        for page in subtype_nouns[subtype]['pages']:
            if not 'tasks' in subtype_nouns[subtype]:
                subtype_nouns[subtype]['tasks'] = page.tasks
            subtype_nouns[subtype]['tasks'].extend(page.tasks)

    for subtype_noun in subtype_nouns:
        print('=======')
        print(subtype_noun)
        tasks = subtype_nouns[subtype_noun]['tasks']
        for task in tasks:
            task_string = '%s%s%s' % (task.object_term.core_noun,
                                      task.cmp,
                                      task.predicate_term)
            #print(task_string)
        print('=======')
# -*- coding: utf-8 -*-
import constants
from pickle_file_loader_for_ex import PickleFileLoaderForExpandedQuery
from pickle_file_saver_for_ex import PickleFileSaverForEx
from path_mover import PathMover
import pdb
import os
import constants

if __name__ == "__main__":
    pfl = PickleFileLoaderForExpandedQuery()
    pfs = PickleFileSaverForEx()
    pm = PathMover()

    original_queries = ["野球 が 上手くなる", "ビリヤード が 上手くなる", "サッカー が 上手くなる", "ハンドボール が 上手くなる"]

    pm.go_or_create_and_go_to(constants.FETCHED_PAGES_DIR_NAME)
    for original_query in original_queries:
        pm.go_or_create_and_go_to(original_query)
        expanded_queries = os.listdir()
        for expanded_query in expanded_queries:
            if expanded_query == ".DS_Store":
                continue
            pm.go_or_create_and_go_to(expanded_query)
            filenames = os.listdir()
            for i, filename in enumerate(filenames):
                if filename == ".DS_Store":
                    continue
                try:
                    page = pfl.load_file(filename)
                except EOFError:
Пример #7
0
# -*- coding: utf-8 -*-
from pickle_file_loader_for_ex import PickleFileLoaderForExpandedQuery
from pickle_file_saver_for_ex import PickleFileSaverForEx
from answer_printer import AnswererPrinter
from path_mover import PathMover
import constants
import pdb

if __name__ == '__main__':
    queries = constants.QUERIES_1
    for query in queries:
        pfl = PickleFileLoaderForExpandedQuery()
        pfs = PickleFileSaverForEx()

        pm = PathMover()

        answerer = pfl.load_answerer_with_query(query)
        if not hasattr(answerer, 'subtype_of_tasks'):
            answerer.set_result_tasks()
            pfs.save_answerer_with_query(answerer, query)

        if not hasattr(answerer, 'instance_of_task_clusters_scores'):
            answerer.set_task_scores()
            pfs.save_answerer_with_query(answerer, query)

        if not hasattr(answerer, 'united_results'):
            answerer.set_united_results()
            pfs.save_answerer_with_query(answerer, query)

        pm.go_or_create_and_go_to('results')
        pm.go_or_create_and_go_to(query)