import pywikibot
import RevisionPuller as RP
import SearchEngine as SE
import PageProcessor as PP

engine = SE.SearchEngine()
processor = PP.PageProcessor()


def get_readable_text_of_old_revision(page_title: str, rev_id: int):
    """
    Returns a string containing a "readable" version of a revision
    :param page_title: A string of the page title
    :param rev_id: The revision number of the desired revision
    :return: A string of the revision's readable text
    """
    page = engine.search(page_title, 1, "nearmatch")[0]
    return processor.getReadableText(RP.get_text_of_old_revision(page, rev_id))


def get_revisions(page_title: str,
                  recent_to_oldest: bool = True,
                  num_revisions=None,
                  start_time: pywikibot.Timestamp = None,
                  end_time: pywikibot.Timestamp = None):
    """
    Returns the last (num_revisions) revisions from a given Wikipedia page
    If all revisions are desired use: get_latest_revisions(page)
    :param page_title: A string containing the title of the desired page
    :param recent_to_oldest: Set to false if we want the revisions in order of oldest to most recent
    :param num_revisions: The number of revisions to be grabbed (set to an integer to set limit to number of revisions grabbed)
Ejemplo n.º 2
0
    parser.add_argument("--mode", choices=["train","eval","repr_code","search"], default='train',
                        help="The mode to run. The `train` mode trains a model;"
                        " the `eval` mode evaluate models in a test set "
                        " The `repr_code/repr_desc` mode computes vectors"
                        " for a code snippet or a natural language description with a trained model.")
    parser.add_argument("--gen", type=int, default='3', help="Number of GA generation")
    parser.add_argument("--chunk_size", type=int, default='20', help="Number of inputs")
    parser.add_argument("--mutation_rate", type=float, default='0.05', help="Mutation Rate")
    parser.add_argument("--verbose",action="store_true", default=True, help="Be verbose")
    return parser.parse_args()


if __name__ == '__main__':
    args = parse_args()
    config = getattr(configs, 'config_'+args.model)()
    engine = SearchEngine.SearchEngine(args, config)

    ##### Define model ######
    logger.info('Build Model')

    #tf.compat.v1.global_variables_initializer()
    model = getattr(models, args.model)(config)  # initialize the model
    model.build()
    model.summary(export_path = "./output/{}/".format(args.model))
    
    optimizer = config.get('training_params', dict()).get('optimizer', 'adam')
    model.compile(optimizer=optimizer)  

    data_path = args.data_path+args.dataset+'/'

import sys
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from vmmpy import *
sys.path.append("RemoteMemoryScanner")
from SearchEngine import *
from UserInterface import *

if __name__ == "__main__":
    app = QApplication(sys.argv)
    search_engine = SearchEngine()
    user_interface = UserInterface(search_engine)
    user_interface.main_window.show()
    sys.exit(app.exec_())
Ejemplo n.º 4
0
def test_steam_miss(test_list):
    test_num = 200
    auc_num = 0
    alph = random.sample('qwertyuiopasdfghjklzxcvbnm', 1)
    for ids in test_list.keys():
        game_name = test_list[ids]
        num = random.randint(0, len(game_name) - 1)
        change = game_name[num]
        new_name = game_name.replace(change, ''.join(alph), 1)
        results = get_search_results(
            "https://store.steampowered.com/search/?term=", new_name)
        if results is None:
            continue
        if len(results) > 10:
            results = results[:10]
        for game in results:
            if str(game['game_id']) == str(ids):
                auc_num += 1
                break
    print('test_num:', test_num, 'accuracy', auc_num / test_num)


if __name__ == "__main__":
    CACHE_DICT = open_cache()
    PS = PorterStemmer()
    search_engine = SearchEngine(config, word_tokenize, PS, isStemming=False)
    # test_list = search_engine.test_auc_zh_steam()
    # test_steam_miss(test_list)

    app.run(debug=True)