def analyze(self): """ not unit-dependant bit congruence directly between ngrams """ if not self._n: raise ParametersNotSet( 'Analysis parameter missing: N-gram size ("n").') tokenlist = list(self.ngrams(self._n)) self._values = BitCongruence.bitCongruenceBetweenTokens(tokenlist) MessageAnalyzer.analyze(self)
def analyze(self): """ bit congruence compared to number of bytes of horizon backwards. :return: """ if not self._analysisArgs: raise ParametersNotSet('Analysis parameter missing: horizon.') horizon = self._analysisArgs[0] self._startskip += horizon tokenlist = self._message.data # tokenlist could also be list of ngrams. bitcongruences = BitCongruence.bitCongruenceBetweenTokens(tokenlist) mbhBitVar = list() for idx, token in enumerate(bitcongruences[horizon:], horizon): congruenceUptoHorizon = numpy.mean(bitcongruences[idx - 2:idx]) mbVar = token - congruenceUptoHorizon mbhBitVar.append(mbVar) self._values = mbhBitVar # add this object to the cache MessageAnalyzer.analyze(self)