diff --git a/artificial_detection/models/smr/sais.py b/artificial_detection/models/smr/sais.py index 252690b..e2d3027 100644 --- a/artificial_detection/models/smr/sais.py +++ b/artificial_detection/models/smr/sais.py @@ -1,3 +1,4 @@ +import numpy as np def construct_suffix_array(string): ta = construct_type_array(string) mapping = construct_alphabet_mapping(string) @@ -167,14 +168,10 @@ def construct_buckets(encoded_string, mapping): def get_bucket_heads(buckets): - heads = [0] - for bucket_size in buckets[:-1]: - heads.append(heads[-1] + bucket_size) + heads = [0] + np.cumsum(buckets[:-1]).tolist() return heads def get_bucket_tails(buckets): - tails = [0] - for bucket_size in buckets[1:]: - tails.append(tails[-1] + bucket_size) + tails = [0] + np.cumsum(buckets[1:]).tolist() return tails