blob: dc7b43eea6f452c88c4af66e61312f18eb616703 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 = [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}
|