The changes necessary to upgrade the kiosk to use python3.7.
[kiosk.git] / profanity_filter.py
index 7b378ccc1213866b516ad0a1723f2e914c207ec6..1c862eb5f54f3769008ec4a73944f15c61bf60e0 100644 (file)
@@ -393,26 +393,26 @@ class profanity_filter:
         for word in brokenStr1:
             if (self.normalize(word) in self.arrBad or
                 word in self.arrBad):
-                print('***** PROFANITY WORD="%s"' % word)
+                print(('***** PROFANITY WORD="%s"' % word))
                 text = text.replace(word, badWordMask[:len(word)])
 
         if len(brokenStr1) > 1:
-            bigrams = zip(brokenStr1, brokenStr1[1:])
+            bigrams = list(zip(brokenStr1, brokenStr1[1:]))
             for bigram in bigrams:
                 phrase = "%s %s" % (bigram[0], bigram[1])
                 if (self.normalize(phrase) in self.arrBad or
                     phrase in self.arrBad):
-                    print('***** PROFANITY PHRASE="%s"' % phrase)
+                    print(('***** PROFANITY PHRASE="%s"' % phrase))
                     text = text.replace(bigram[0], badWordMask[:len(bigram[0])])
                     text = text.replace(bigram[1], badWordMask[:len(bigram[1])])
 
         if len(brokenStr1) > 2:
-            trigrams = zip(brokenStr1, brokenStr1[1:], brokenStr1[2:])
+            trigrams = list(zip(brokenStr1, brokenStr1[1:], brokenStr1[2:]))
             for trigram in trigrams:
                 phrase = "%s %s %s" % (trigram[0], trigram[1], trigram[2])
                 if (self.normalize(phrase) in self.arrBad or
                     phrase in self.arrBad):
-                    print('***** PROFANITY PHRASE="%s"' % phrase)
+                    print(('***** PROFANITY PHRASE="%s"' % phrase))
                     text = text.replace(trigram[0], badWordMask[:len(trigram[0])])
                     text = text.replace(trigram[1], badWordMask[:len(trigram[1])])
                     text = text.replace(trigram[2], badWordMask[:len(trigram[2])])
@@ -423,25 +423,25 @@ class profanity_filter:
         for word in brokenStr1:
             if (self.normalize(word) in self.arrBad or
                 word in self.arrBad):
-                print('***** PROFANITY WORD="%s"' % word)
+                print(('***** PROFANITY WORD="%s"' % word))
                 return True
 
         if len(brokenStr1) > 1:
-            bigrams = zip(brokenStr1, brokenStr1[1:])
+            bigrams = list(zip(brokenStr1, brokenStr1[1:]))
             for bigram in bigrams:
                 phrase = "%s %s" % (bigram[0], bigram[1])
                 if (self.normalize(phrase) in self.arrBad or
                     phrase in self.arrBad):
-                    print('***** PROFANITY PHRASE="%s"' % phrase)
+                    print(('***** PROFANITY PHRASE="%s"' % phrase))
                     return True
 
         if len(brokenStr1) > 2:
-            trigrams = zip(brokenStr1, brokenStr1[1:], brokenStr1[2:])
+            trigrams = list(zip(brokenStr1, brokenStr1[1:], brokenStr1[2:]))
             for trigram in trigrams:
                 phrase = "%s %s %s" % (trigram[0], trigram[1], trigram[2])
                 if (self.normalize(phrase) in self.arrBad or
                     phrase in self.arrBad):
-                    print('***** PROFANITY PHRASE="%s"' % phrase)
+                    print(('***** PROFANITY PHRASE="%s"' % phrase))
                     return True
 
         return False