diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2011-06-06 04:24:43 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2011-06-06 04:24:43 +0000 |
commit | ccd2c7338d8bcbacffe531d9c43493f7f8035517 (patch) | |
tree | 2b28f03c11c0f7c7fb5f8ac70de88f992199b019 /Master/texmf/scripts/texdoc/score.tlu | |
parent | e1ed0075e33f4d74cc66bf8e13f2e2ccd3d8fdbf (diff) |
texdoc 0.81
git-svn-id: svn://tug.org/texlive/trunk@22812 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/scripts/texdoc/score.tlu')
-rw-r--r-- | Master/texmf/scripts/texdoc/score.tlu | 40 |
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, +} |