示例#1
0
    def __init__(self):
        self.core = search_core()
        self.new_query_list = []
        super(mainWindow, self).__init__()
        self.setWindowTitle('Search Engine')
        self.setWindowIcon(QtGui.QIcon('hiit.jpg'))
        self.showMaximized()

        # --------- Layouts ----------
        self.main_layout = QtGui.QVBoxLayout()
        self.configuration_section = QtGui.QGridLayout()
        self.top_topics_section = QtGui.QHBoxLayout()
        self.top_topics_section_content = QtGui.QHBoxLayout()
        self.top_topics_section_configurations = QtGui.QVBoxLayout()
        self.top_articles_section = QtGui.QHBoxLayout()

        # ----------- Button and Objects Declaration -----------
        self.label_query = QtGui.QLabel('Enter the query:')
        self.label_number_of_topwords = QtGui.QLabel('# Top words: ')
        self.label_number_of_toptopics = QtGui.QLabel('# Top topics: ')
        self.edit_number_of_topwords = QtGui.QLineEdit()
        self.edit_number_of_topwords.setMaximumWidth(50)
        self.edit_number_of_toptopics = QtGui.QLineEdit()
        self.edit_number_of_toptopics.setMaximumWidth(50)
        self.edit_query = QtGui.QLineEdit()

        self.edit_reset_template = QtGui.QTextEdit()
        self.btn_go = QtGui.QPushButton('Go')
        self.btn_reset = QtGui.QPushButton('Reset')
        self.btn_reset.setDisabled(True)
        self.btn_hierarchical_model = QtGui.QPushButton('Hierarchical Mode')
        self.btn_hierarchical_model.setDisabled(True)
        self.btn_next_round = QtGui.QPushButton('Next Round')
        self.btn_next_round.setDisabled(True)

        #self.example_text_area = QtGui.QTextEdit()

        # ------------- validator --------------
        self.edit_number_of_toptopics.setValidator(QtGui.QIntValidator(1, 15))
        self.edit_number_of_topwords.setValidator(QtGui.QIntValidator(1, 30))

        self.initUI()
        self.show()
示例#2
0
from flask import Flask, request, send_from_directory, render_template, jsonify
from engine_core import search_core
import json

app = Flask(__name__)
app.debug = True

search_service = search_core()
iteration_data = {}
author_mapping = {}
id_iterator = 0

def search_objects_to_topics(search_objects, desired_number_topics=10, desired_number_top_words=10):
    search_service.set_query(search_objects)
    search_service.set_desired_number_topics(desired_number_topics)
    search_service.set_desired_number_top_words(desired_number_top_words)
    top_words_results, top_articles_result = search_service.search()

    global iteration_data, id_iterator, author_mapping

    topics = []
    iteration_data = {}
    author_mapping = {}
    id_iterator = 0
    author_iterator = 0

    for topic in top_words_results:
        topic_name = topic[0]
        t = { 'topic': topic_name }
        t['keywords'] = []