# Path: preimage/features/string_feature_space.py
# def build_feature_space_without_positions(alphabet, n, Y):
#     """Create the feature space without considering the position of the n-gram in the strings
# 
#     Parameters
#     ----------
#     alphabet : list
#         List of letters.
#     n : int
#         N-gram length.
#     Y : array, [n_samples, ]
#         Training strings.
# 
#     Returns
#     -------
#     feature_space : sparse matrix, shape = [n_samples, len(alphabet)**n]
#         Sparse matrix representation of the n-grams in each training string, where n_samples is the number of samples
#         in Y.
#     """
#     n = int(n)
#     n_examples = numpy.array(Y).shape[0]
#     n_gram_to_index = get_n_gram_to_index(alphabet, n)
#     index_pointers, indexes, data = __initialize_pointers_indexes_data(n_examples)
#     __build_y_pointers_indexes_data(index_pointers, indexes, data, n, n_gram_to_index, Y)
#     feature_space = __build_csr_matrix(index_pointers, indexes, data, n_examples, len(n_gram_to_index))
#     return feature_space


import numpy
from preimage.features.string_feature_space import build_feature_space_without_positions



class NGramFeatureSpace:
    """Output feature space for the N-Gram Kernel

    Creates a sparse matrix representation of the n-grams in each training string. This is used to compute the weights
    of the graph during the inference phase.

    Attributes
    ----------
    feature_space : sparse matrix, shape = [n_samples, len(alphabet)**n]
        Sparse matrix representation of the n-grams in each training string, where n_samples is the number of training
        samples.
    """

    def __init__(self, alphabet, n, Y, is_normalized):
        """Create the output feature space for the N-Gram Kernel

        Parameters
        ----------
        alphabet : list
            list of letters
        n : int
            N-gram length.
        Y : array, [n_samples, ]
            The training strings.
        is_normalized : bool
            True if the feature space should be normalized, False otherwise.
        """

# Path: preimage/features/string_feature_space.py
# def build_feature_space_without_positions(alphabet, n, Y):
#     """Create the feature space without considering the position of the n-gram in the strings
# 
#     Parameters
#     ----------
#     alphabet : list
#         List of letters.
#     n : int
#         N-gram length.
#     Y : array, [n_samples, ]
#         Training strings.
# 
#     Returns
#     -------
#     feature_space : sparse matrix, shape = [n_samples, len(alphabet)**n]
#         Sparse matrix representation of the n-grams in each training string, where n_samples is the number of samples
#         in Y.
#     """
#     n = int(n)
#     n_examples = numpy.array(Y).shape[0]
#     n_gram_to_index = get_n_gram_to_index(alphabet, n)
#     index_pointers, indexes, data = __initialize_pointers_indexes_data(n_examples)
#     __build_y_pointers_indexes_data(index_pointers, indexes, data, n, n_gram_to_index, Y)
#     feature_space = __build_csr_matrix(index_pointers, indexes, data, n_examples, len(n_gram_to_index))
#     return feature_space


# Path: preimage/features/n_gram_feature_space.py
import numpy
from preimage.features.string_feature_space import build_feature_space_without_positions




class NGramFeatureSpace:
    """Output feature space for the N-Gram Kernel

    Creates a sparse matrix representation of the n-grams in each training string. This is used to compute the weights
    of the graph during the inference phase.

    Attributes
    ----------
    feature_space : sparse matrix, shape = [n_samples, len(alphabet)**n]
        Sparse matrix representation of the n-grams in each training string, where n_samples is the number of training
        samples.
    """

    def __init__(self, alphabet, n, Y, is_normalized):
        """Create the output feature space for the N-Gram Kernel

        Parameters
        ----------
        alphabet : list
            list of letters
        n : int
            N-gram length.
        Y : array, [n_samples, ]
            The training strings.
        is_normalized : bool
            True if the feature space should be normalized, False otherwise.
        """

        self.feature_space = build_feature_space_without_positions(alphabet, n, Y)