From 0b0e02875dbc4d7d795cafe6e5720aa66b32e1ac Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 2 Nov 2024 13:41:36 +0100 Subject: Naive approach to disk-based masking directly on the trigrams --- reading.lua | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'reading.lua') diff --git a/reading.lua b/reading.lua index 2b74446..6c910e2 100644 --- a/reading.lua +++ b/reading.lua @@ -1,3 +1,8 @@ +local function trigram_to_value (a, b, c) + return a * 25 + b * 5 + c +end + + local function next_trigram (message, index) index = (index or 0) + 1 local offset = (index - 1) * 3 @@ -15,23 +20,33 @@ local function next_value (message, index) if not index then return nil end - return index, a * 25 + b * 5 + c + return index, trigram_to_value(a, b, c) end local reading = { + trigram_to_value = trigram_to_value, next_trigram = next_trigram, next_value = next_value, } function reading.trigrams (message, start) - return next_trigram, message, start + return next_trigram, message, start or 0 end function reading.values (message, start) - return next_value, message, start + return next_value, message, start or 0 +end + + +function reading.tvalues (message) + local values = {} + for _, value in reading.values(message) do + table.insert(values, value) + end + return values end -- cgit v1.1