summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts/texdoc/score.tlu
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf/scripts/texdoc/score.tlu')
-rw-r--r--Master/texmf/scripts/texdoc/score.tlu40
1 files changed, 15 insertions, 25 deletions
diff --git a/Master/texmf/scripts/texdoc/score.tlu b/Master/texmf/scripts/texdoc/score.tlu
index 75022e41288..697f0cf1b2a 100644
--- a/Master/texmf/scripts/texdoc/score.tlu
+++ b/Master/texmf/scripts/texdoc/score.tlu
@@ -1,15 +1,6 @@
--- scoring functions for texdoc
---[[
-Copyright 2008, 2009 Manuel Pégourié-Gonnard
-Distributed under the terms of the GNU GPL version 3 or later.
-See texdoc.tlu for details.
---]]
-
--- Load a local environment. See texdoc.tlu for details.
-local L = {}
-load_env(L, {
- 'config', 'parse_zip',
-})
+-- score.tlu: scoring functions for texdoc
+--
+-- Manuel Pégourié-Gonnard, GPLv3, see texdoclib.tlu for details
-- shared variables
local global_adjscore, spec_adjscore = {}, {}
@@ -57,8 +48,6 @@ end
-- set the score of a docfile
function set_score(df, original_kw)
- -- scoring is irrelevant in regex mode
- if config.mode == 'regex' then df.score = 0 return end
-- scoring is case-insenstitive (patterns are already lowercased)
local name = string.lower(df.shortname)
deb_print('score', '----------')
@@ -96,10 +85,11 @@ function set_score(df, original_kw)
if df.details then
if string.find(string.lower(df.details), 'readme') then
score = score + 0.1
+ deb_print('score', 'Catalogue "readme" bonus: +0.1')
else
score = score + 2.5
+ deb_print('score', 'Catalogue details bonus: +2.5')
end
- deb_print('score', string.format('New score: %g from metadata', score))
end
-- adjust from keyword-specific tables
if df.tree > -1 and spec_adjscore[original_kw] then
@@ -157,14 +147,14 @@ function heuristic_score(file, pat)
end
end
end
- -- if extension is bad, score gets < 0
+ -- if extension is bad, score becomes an epsilon
local ext = config.ext_list[ext_pos(file)]
if ext and config.badext_list_inv[ext] and score > 0 then
- upscore(-1, 'bad extension', true)
+ upscore(0.1, 'bad extension', true)
end
-- if basename is bad, score gets < 0
if has_bad_basename(file) and score > 0 then
- upscore(-1, 'bad basename', true)
+ upscore(0.1, 'bad basename', true)
end
-- bonus for being in the right directory
if string.find('/'..file, '/'..pat..'/', 1, true) and not slash then
@@ -287,10 +277,10 @@ function sort_doclist(dl, original_kw)
table.sort(dl, docfile_order)
end
--- export a few symbols
-export_symbols(L, {
- 'sort_doclist',
- 'docfile_quality',
- 'ext_pos',
- 'confline_to_score',
-})
+return {
+ sort_doclist = sort_doclist,
+ docfile_quality = docfile_quality,
+ ext_pos = ext_pos,
+ is_exact = is_exact,
+ confline_to_score = confline_to_score,
+}