mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
*: luacheck fixes (#8368)
These weren't caught during the Japanese support plugin review. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -37,7 +37,7 @@ local RULE_TYPES = {
|
||||
}
|
||||
|
||||
local function toRuleTypes(...)
|
||||
final = 0
|
||||
local final = 0
|
||||
for _, ruleType in ipairs({...}) do
|
||||
if RULE_TYPES[ruleType] then
|
||||
final = bit.bor(final, RULE_TYPES[ruleType])
|
||||
@@ -102,7 +102,7 @@ function Deinflector:deinflectVerbatim(text)
|
||||
-- Check if we've already found this deinflection. If so,
|
||||
-- that means there was a shorter reason path to it and
|
||||
-- this deinflection is almost certainly theoretical.
|
||||
new_term = current.term:sub(1, -#rule.kanaIn-1) .. rule.kanaOut
|
||||
local new_term = current.term:sub(1, -#rule.kanaIn-1) .. rule.kanaOut
|
||||
if not seen[new_term] then
|
||||
table.insert(results, makeDeinflectionResult(
|
||||
new_term,
|
||||
@@ -435,14 +435,14 @@ function Deinflector:init()
|
||||
DEFAULT_TEXT_CONVERSIONS
|
||||
if self.rules ~= nil then return end -- already loaded
|
||||
|
||||
--- @todo Maybe make this location configurable?
|
||||
inflections = parsePluginJson("yomichan-deinflect.json")
|
||||
--- @todo Maybe make this location configurable or look in the user-controlled data directory too?
|
||||
local inflections = parsePluginJson("yomichan-deinflect.json")
|
||||
|
||||
-- Normalise the reasons and convert the rules to the rule_types bitflags.
|
||||
self.rules = {}
|
||||
local nrules, nvariants = 0, 0
|
||||
for reason, rules in pairs(inflections) do
|
||||
variants = {}
|
||||
local variants = {}
|
||||
for i, variant in ipairs(rules) do
|
||||
variants[i] = {
|
||||
kanaIn = variant.kanaIn,
|
||||
|
||||
@@ -19,11 +19,9 @@
|
||||
-- together in order to reduce the impact we have on text selection.
|
||||
|
||||
local Deinflector = require("deinflector")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local LanguageSupport = require("languagesupport")
|
||||
local ReaderDictionary = require("apps/reader/modules/readerdictionary")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local JSON = require("json")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
@@ -77,7 +75,7 @@ function Japanese:onWordLookup(args)
|
||||
-- extra work to be efficient (since we need to remove the last
|
||||
-- character in the string).
|
||||
|
||||
results = self.deinflector:deinflect(text)
|
||||
local results = self.deinflector:deinflect(text)
|
||||
logger.dbg("japanese.koplugin: deinflection of", text, "results:", results)
|
||||
|
||||
--- @todo Pass up the reasons list (formatted Yomichan style) to the
|
||||
@@ -86,7 +84,7 @@ function Japanese:onWordLookup(args)
|
||||
-- metadata that we have to pass through from the lookup to the
|
||||
-- dictionary pop-up.
|
||||
|
||||
candidates = {}
|
||||
local candidates = {}
|
||||
for i, result in ipairs(results) do
|
||||
candidates[i] = result.term
|
||||
end
|
||||
@@ -112,7 +110,6 @@ end
|
||||
-- @see languagesupport.improveWordSelection
|
||||
-- @see languagesupport.registerPlugin
|
||||
function Japanese:onWordSelection(args)
|
||||
local pos0, pos1 = args.pos0, args.pos1
|
||||
local callbacks = args.callbacks
|
||||
local current_text = args.text
|
||||
|
||||
@@ -128,7 +125,7 @@ function Japanese:onWordSelection(args)
|
||||
-- We reset the end of the range to pos0+1 because crengine will select
|
||||
-- half-width katakana (カタカナ) in strange ways that often overshoots the
|
||||
-- end of words.
|
||||
pos1 = callbacks.get_next_char_pos(pos0)
|
||||
local pos0, pos1 = args.pos0, callbacks.get_next_char_pos(args.pos0)
|
||||
|
||||
-- We try to advance the end position until we hit a word.
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user