#!/usr/bin/env python """ """ __author__ = "Théo de la Hogue" __credits__ = [] __copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)" __license__ = "BSD" from typing import TypeVar, Tuple, Any from dataclasses import dataclass, field from argaze import GazeFeatures @dataclass class AOIScanPathAnalyzer(GazeFeatures.AOIScanPathAnalyzer): """Implementation of N-gram algorithm as ... """ def __post_init__(self): pass def analyze(self, aoi_scan_path: GazeFeatures.AOIScanPathType, n: int) -> list: """Analyze aoi scan.""" assert(len(aoi_scan_path) > 1) sequence = str(aoi_scan_path) ngrams = zip(*[sequence[i:] for i in range(n)]) ngrams = [ngram for ngram in ngrams] return {tuple([aoi_scan_path.get_letter_aoi(l) for l in ngram]) : ngrams.count(ngram) for ngram in ngrams}