<commit_before>import os.path as op
import sys
import getopt

from retrieval.flickrwrapper import FlickrWrapper
from analysis import process
from display import plothelper
from features import sift, extract
from runmode import RunMode
from dataset.dataset import DataSet


class RsBundler:

    def __init__(self, api_key, tag):
        self.__data = DataSet(tag, op.dirname(op.abspath(__file__)))
        self.__flickr = FlickrWrapper(api_key)

    def run(self):
        self.download()
        self.extract()
        self.process()
        self.plot_result()
        
    def download(self):
        self.__flickr.download(self.__data)

    def extract(self):
        sift.extract(self.__data)
        extract.extract(self.__data)

    def process(self):
        process.process(self.__data)
        process.closest(self.__data)

    def plot_result(self):
        images, pc_projections, pcs = process.load_principal_components(self.__data.result_path)
        closest_group, representative = process.load_closest(self.__data.result_path)

        save_path = self.__data.plot_path if self.__data.config.save_plot else None

        for pc_plot in self.__data.config.pc_plots:
            plothelper.plot_pca_images(self.__data.image_path, images, pc_projections, pc_plot[0], pc_plot[1],
                                       save_path=save_path, ticks=self.__data.config.ticks)

        plothelper.plot_result(self.__data.image_path, images, closest_group, representative,
                               save_path=save_path, cols=self.__data.config.columns)
 <commit_msg>Calling structure plot from bundler.<commit_after>import os.path as op
import sys
import getopt

from retrieval.flickrwrapper import FlickrWrapper
from analysis import process
from analysis import kmeans
from display import plothelper
from features import sift, extract
from runmode import RunMode
from dataset.dataset import DataSet


class RsBundler:

    def __init__(self, api_key, tag):
        self.__data = DataSet(tag, op.dirname(op.abspath(__file__)))
        self.__flickr = FlickrWrapper(api_key)

    def run(self):
        self.download()
        self.extract()
        self.process()
        self.plot_result()
        
    def download(self):
        self.__flickr.download(self.__data)

    def extract(self):
        sift.extract(self.__data)
        extract.extract(self.__data)

    def process(self):
        process.process(self.__data)
        process.closest(self.__data)
        kmeans.structures(self.__data)

    def plot_result(self):
        images, pc_projections, pcs = process.load_principal_components(self.__data.result_path)
        closest_group, representative = process.load_closest(self.__data.result_path)
        centroids, structures = kmeans.load_structures(self.__data.result_path)

        save_path = self.__data.plot_path if self.__data.config.save_plot else None

        for pc_plot in self.__data.config.pc_plots:
            plothelper.plot_pca_images(self.__data.image_path, images, pc_projections, pc_plot[0], pc_plot[1],
                                       save_path=save_path, ticks=self.__data.config.ticks)

        plothelper.plot_result(self.__data.image_path, images, closest_group, representative,
                               save_path=save_path, cols=self.__data.config.columns)

        plothelper.plot_structures(self.__data.image_path, images, structures)
 
{'fraction_non_alphanumeric': 0.0854876615746181, 'fraction_numerical': 0.0011750881316098707, 'mean_word_length': 2.99179366940211, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1245543', 'n_tokens_mistral': 1013, 'n_tokens_neox': 971, 'n_words': 201}