Esempio n. 1
0
    def __init__(self, server_ip, server_port, database):
        self.client = MongoClient(server_ip, server_port, connect=True)
        self.database = database

        self.twitter_controller = TwitterController(self)
        self.analysis_controller = AnalysisController(self.client, database)

        self.dao_collection_tags = DAOTags(self.client, self.database)
Esempio n. 2
0
class SilverEye:
    def __init__(self, server_ip, server_port, database):
        self.client = MongoClient(server_ip, server_port, connect=True)
        self.database = database

        self.twitter_controller = TwitterController(self)
        self.analysis_controller = AnalysisController(self.client, database)

        self.dao_collection_tags = DAOTags(self.client, self.database)

    def start(self):
        keywords = self.dao_collection_tags.get_array_of_the_name_of_classified_tags()
        self.twitter_controller.start(keywords)

    def stop(self):
        self.twitter_controller.stop()

    def analyze_tweet(self, tweet):
        self.analysis_controller.analyze_tweet(tweet)

    def analyse_temporal_time(self, init_time=0):
        self.analysis_controller.analyse_temporal_lines(init_time)

    def analyze_global_results(self):
        self.analysis_controller.overall_analysis()
Esempio n. 3
0
    def start_hsne(self, data, data_file, hsne_file, label_file):
        """Initiate the embedding iteration in the analysis GUI"""
        print("Created hSNE")
        hsne = nptsne.HSne(True)

        number_of_scales = self.model_gui.scales
        print(f"Number of scales: {number_of_scales}")
        if hsne_file is None:
            print("hSNE from scratch")
            hsne.create_hsne(data, number_of_scales)
            hsne_file = data_file.with_suffix('.hsne')
            hsne.save(str(hsne_file))
        else:
            print("existing hSNE")
            hsne.load_hsne(data, str(hsne_file))

        print("start analysis model")
        self.data = data
        self.analysis_model = hsne_analysis.AnalysisModel(
            hsne, self.embedder_type)

        top_analysis = self.analysis_model.top_analysis

        all_analyses_per_scale = {
            top_analysis.scale_id: {
                top_analysis.id: top_analysis
            }
        }

        self.__set_labels_and_color_norm(label_file)

        # The AnalysisGui is non-blocking
        # start with an analysis GUI containing all top scale landmarks
        is_top_level = True
        self.im_size = (0, 0)
        if self.model_gui.demo_type in [
                DemoType.LABELLED_DEMO, DemoType.HYPERSPECTRAL_DEMO
        ]:
            self.im_size = (self.model_gui.im_size_x, self.model_gui.im_size_y)
        top_analysis_gui = AnalysisController(self.model_gui.demo_type,
                                              self.add_analysis,
                                              self.remove_analysis,
                                              self.analysis_stopped)

        if self.model_gui.demo_type is DemoType.POINT_DEMO:
            top_analysis_gui.set_metapath(self.labelcolor_filename)

        top_analysis_gui.start_embedding(self.data, top_analysis,
                                         self.model_gui.iterations,
                                         self.im_size, False, self.labels,
                                         self.color_norm)
        print(f"Top analysis has {top_analysis.number_of_points} points")
        self.analysis_guis[top_analysis.id] = top_analysis_gui
        self.queue_new_analysis(top_analysis)
        # Queue is used to pass changes in the analyses to the ModelGui
        # The ModelGui is blocking
        self.model_gui.set_analysis_model(self.analysis_model)
Esempio n. 4
0
    def add_analysis(self, analysis, selected_indexes):
        """Handle 2.) AnalysisEvent.ADDED
            Callback to start a sub analysis in the analysis model"""
        print("Drilling down to new analysis")
        new_analysis = self.analysis_model.add_new_analysis(
            analysis, selected_indexes)
        print("Updated analysis hierarchy: ")
        print(self.analysis_model.analysis_container)
        print("Starting analysis GUI")

        analysis_gui = AnalysisController(self.model_gui.demo_type,
                                          self.add_analysis,
                                          self.remove_analysis,
                                          self.analysis_stopped)

        if self.model_gui.demo_type is DemoType.POINT_DEMO:
            analysis_gui.set_metapath(self.labelcolor_filename)

        analysis_gui.start_embedding(self.data, new_analysis,
                                     self.model_gui.iterations, self.im_size,
                                     False, self.labels, self.color_norm)
        self.analysis_guis[new_analysis.id] = analysis_gui
        self.queue_new_analysis(new_analysis)