From 3dccc9f4e09265c8c3e84b584e169269e4083048 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 20 Nov 2018 13:13:11 +0000 Subject: [PATCH] Keep a track of different scripts in a message, round score to 2 decimal places (mixed_unicode.py) --- modules/mixed_unicode.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/mixed_unicode.py b/modules/mixed_unicode.py index db59c914..8beea0d9 100644 --- a/modules/mixed_unicode.py +++ b/modules/mixed_unicode.py @@ -49,12 +49,14 @@ class Module(ModuleManager.BaseModule): last_script = None last_was_separator = False score = 0 + scripts = set([]) for char in event["message"]: if char in WORD_SEPERATORS: last_was_separator = True else: script = self._detect_script(char) + scripts.add(script) if not script == Script.Unknown: if last_script and not script == last_script: score += 1 @@ -66,5 +68,6 @@ class Module(ModuleManager.BaseModule): last_was_separator = False score = score/(len(event["message"])/SCORE_LENGTH) + score = round(score, 2) if score > 0: - self.log.trace("Message given a mixed-unicode score of %d", [score]) + self.log.trace("Message given a mixed-unicode score of %f", [score])