aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/GazeAnalysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze/GazeAnalysis')
-rw-r--r--src/argaze/GazeAnalysis/NGram.py34
-rw-r--r--src/argaze/GazeAnalysis/__init__.py2
2 files changed, 35 insertions, 1 deletions
diff --git a/src/argaze/GazeAnalysis/NGram.py b/src/argaze/GazeAnalysis/NGram.py
new file mode 100644
index 0000000..b985d7d
--- /dev/null
+++ b/src/argaze/GazeAnalysis/NGram.py
@@ -0,0 +1,34 @@
+#!/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 = [tuple([aoi_scan_path.get_letter_aoi(l) for l in ngram]) for ngram in ngrams]
+
+ return {ngram : ngrams.count(ngram) for ngram in ngrams}
diff --git a/src/argaze/GazeAnalysis/__init__.py b/src/argaze/GazeAnalysis/__init__.py
index 0d5cd2c..d82969d 100644
--- a/src/argaze/GazeAnalysis/__init__.py
+++ b/src/argaze/GazeAnalysis/__init__.py
@@ -2,4 +2,4 @@
.. include:: README.md
"""
__docformat__ = "restructuredtext"
-__all__ = ['DispersionThresholdIdentification', 'VelocityThresholdIdentification', 'TransitionMatrix', 'CoefficientK', 'LempelZivComplexity'] \ No newline at end of file
+__all__ = ['DispersionThresholdIdentification', 'VelocityThresholdIdentification', 'TransitionMatrix', 'CoefficientK', 'LempelZivComplexity', 'NGram'] \ No newline at end of file