index koinc. s mezerami
authorTomas Musil <tomik.musil@gmail.com>
Fri, 23 Mar 2012 08:35:33 +0000 (09:35 +0100)
committerTomas Musil <tomik.musil@gmail.com>
Fri, 23 Mar 2012 08:35:33 +0000 (09:35 +0100)
koincidence.py
robot.py

index 07231b7..5a41dfa 100644 (file)
@@ -1,8 +1,10 @@
 from ocesavac import ocesat
 from collections import deque
 
-def index_koincidence(text):
-    t = ocesat(text, False) #zatim bez mezer
+def index_koincidence(text, mezery=False):
+    t = ocesat(text, mezery)
+    if mezery:
+        t = t[1:-1]
     deq = deque(t)
     shod = 0
     for i in range(1, len(t)):
index a49c337..a4c9c5c 100755 (executable)
--- a/robot.py
+++ b/robot.py
@@ -129,9 +129,12 @@ for char in sorted(freq, key=freq.get, reverse=True):
                    float(freq[char])/celkem))
 
 # Index koincidence
-# TODO verze s mezerami
-analyza.append("\nIndexy koincidence (vzdy bez mezer):")
-analyza.append(koincidence.tabulka_indexu(zprava))
+if mod_m:
+    analyza.append("\nIndex koincidence (s mezerami):")
+    analyza.append(koincidence.index_koincidence(zprava))
+if mod_x:
+    analyza.append("\nIndexy koincidence (bez mezer):")
+    analyza.append(koincidence.tabulka_indexu(zprava))
 
 # Jakobsen
 if mod_m: