]> git.eshelyaron.com Git - dict.git/commitdiff
FIXED: don't include irrelevant candidates in apropos results
authorEshel Yaron <me@eshelyaron.com>
Fri, 21 Oct 2022 08:36:09 +0000 (11:36 +0300)
committerEshel Yaron <me@eshelyaron.com>
Fri, 21 Oct 2022 08:36:09 +0000 (11:36 +0300)
* sweep.pl (sweep_predicate_apropos/2): filter candidates by minimum
match quality.

sweep.pl

index 7b4a8d001f5e9e436d61e68d6ee199ecb5b1ee7d..cf29c390656c440e899242d1e1b25974471cec21 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
 :- use_module(library(http/html_write)).
 :- use_module(library(prolog_pack)).
 
+:- if(exists_source(library(help))).
+:- use_module(library(help)).
+:- endif.
+
+
 :- meta_predicate with_buffer_stream(-, +, 0).
 
 :- dynamic sweep_current_color/3,
@@ -523,14 +528,14 @@ sweep_predicate_location(FN, [Path|Line]) :-
 sweep_predicate_apropos(Query0, Matches) :-
     atom_string(Query, Query0),
     findall([S,Path|Line],
-            (prolog_help:apropos(Query, M:F/N, _, _),
-             format(string(S), '~w:~W/~w', [M, F, [quoted(true), character_escapes(true)], N]),
+            (prolog_help:apropos(Query, M:F/N, _, P), P >= 0.3,
+             format(string(S), '~W', [M:F/N, [quoted(true), character_escapes(true)]]),
              pi_head(F/N, Head),
              sweep_predicate_location_(M, Head, Path, Line)),
             Matches, Tail),
     findall([S,Path],
-            (prolog_help:apropos(Query, F/N, _, _),
-             format(string(S), '~W/~w', [F, [quoted(true), character_escapes(true)], N]),
+            (prolog_help:apropos(Query, F/N, _, P), P >= 0.3,
+             format(string(S), '~W', [F/N, [quoted(true), character_escapes(true)]]),
              pi_head(F/N, Head),
              sweep_predicate_location_(Head, Path, Line)),
             Tail).