Browse Source

fix bad recognize rule

Xi Ruoyao 4 years ago
parent
commit
573c5f1d25
1 changed files with 17 additions and 17 deletions
  1. 17 17
      recog.py

+ 17 - 17
recog.py

@@ -16,23 +16,23 @@ def list_have_continue_maybe_indoor(l):
         last_indoor = indoor
     return False
 
-def check_entry(before, curr, after):
-    if not data.have_location(curr):
-        return None
-    if count_have_location(before) < 9:
-        return None
-    if not data.maybe_entry(curr):
-        return None
-    if data.maybe_entry(before[-1]):
-        return None
-    if not list_have_continue_maybe_indoor(after):
-        return None
-    return before[-1]
-
 def recognize_entries(l):
+    print(l)
     ret = []
-    for i in range(59, len(l) - 12):
-        x = check_entry(l[i-59:i], l[i], l[i+1:i+13])
-        if not x is None:
-            ret.append(x)
+    j = 0
+    for i in range(len(l)):
+        while j < len(l) and l[j].timestamp - l[i].timestamp < 60:
+            j += 1
+        if j - i < 12:
+            continue
+        if count_have_location(l[i:j]) < j - i:
+            continue
+        if j >= len(l) or not data.maybe_entry(l[j]):
+            continue
+        if data.maybe_entry(l[j-1]):
+            continue
+        if not list_have_continue_maybe_indoor(l[j+1:j+13]):
+            continue
+
+        ret.append(l[j-1])
     return ret