View source with raw comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  2018, VU University Amsterdam
    7    All rights reserved.
    8
    9    Redistribution and use in source and binary forms, with or without
   10    modification, are permitted provided that the following conditions
   11    are met:
   12
   13    1. Redistributions of source code must retain the above copyright
   14       notice, this list of conditions and the following disclaimer.
   15
   16    2. Redistributions in binary form must reproduce the above copyright
   17       notice, this list of conditions and the following disclaimer in
   18       the documentation and/or other materials provided with the
   19       distribution.
   20
   21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   24    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   25    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   26    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   27    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   28    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   29    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   31    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   32    POSSIBILITY OF SUCH DAMAGE.
   33*/
   34
   35:- module(doc_words,
   36          [ doc_related_word/3,         % +Term, -Related, -Distance
   37            prolog_identifier_part/1   % ?Part
   38          ]).   39:- use_module(library(lists)).   40:- use_module(library(atom)).   41
   42:- use_module(man_index).

Reason about Prolog jargon

This module is shared between PlDoc and apropos/1 and collects information about the Prolog jargon to enhance recall and precision of the search. One could call it an ontology, but I guess that is a bit too much honour. */

   52:- multifile
   53    prolog:doc_object_summary/4.
 doc_related_word(+Term, -Related, -Distance) is nondet
True when Related is a word that is related to Term. Map some commonly known concepts to their Prolog related term. Where do we find a comprehensive list of these?
   61doc_related_word(In, Out, Distance) :-
   62    related(In, Out, 1, Distance, [In]).
   63
   64related(T, T, D, D, _).
   65related(In, Out, D0, D, Visited) :-
   66    (   synonym(In, Out0, D1)
   67    ;   synonym(Out0, In, D1)
   68    ),
   69    \+ memberchk(Out0, Visited),
   70    D2 is D0*D1,
   71    D2 > 0.2,
   72    related(Out0, Out, D2, D, [Out0|Visited]).
   73
   74synonym(abs,       absolute,    0.7).
   75synonym(add,       append,      0.3).
   76synonym(add,       assert,      0.3).
   77synonym(append,    concatenate, 0.5).
   78synonym(arg,       argument,	0.8).
   79synonym(argument,  parameter,   0.7).
   80synonym(at,        on,		0.3).
   81synonym(cancel,    stop,	0.3).
   82synonym(ceil,      ceiling,     0.7).
   83synonym(char,      character,   0.8).
   84synonym(clone,     duplicate,   0.3).
   85synonym(close,     destroy,     0.3).
   86synonym(comma,	   conjunction, 0.3).
   87synonym(concat,    concatenate, 0.8).
   88synonym(console,   terminal,    0.7).
   89synonym(consult,   compile,     0.7).
   90synonym(cos,       cosine,      0.9).
   91synonym(create,    clone,       0.3).
   92synonym(create,    fork,        0.3).
   93synonym(create,    make,        0.3).
   94synonym(create,    new,         0.3).
   95synonym(del,       delete,	0.7).
   96synonym(delete,    remove,      0.3).
   97synonym(delete,    unregister,  0.3).
   98synonym(destroy,   delete,      0.3).
   99synonym(destroy,   unregister,  0.3).
  100synonym(dir,       directory,	0.7).
  101synonym(div,       divide,	0.5).
  102synonym(elem,      element,     0.7).
  103synonym(element,   member,      0.3).
  104synonym(eq,        equal,       0.5).
  105synonym(equal,     equivalent,  0.9).
  106synonym(error,     catch,       0.5).
  107synonym(error,     exception,   0.8).
  108synonym(error,     throw,       0.5).
  109synonym(eval,      evaluate,    0.7).
  110synonym(exec,	   execute,     0.7).
  111synonym(exit,      halt,        0.9).
  112synonym(fast,      quick,       0.7).
  113synonym(file,      srcdest,     0.9).
  114synonym(file,      stream,      0.3).
  115synonym(find,      search,      0.7).
  116synonym(float,     double,      0.7).
  117synonym(folder,    directory,	0.7).
  118synonym(function,  procedure,   0.3).
  119synonym(http,      https,       0.3).
  120synonym(http,      url,         0.3).
  121synonym(inf,       infinite,    0.7).
  122synonym(int,	   integer,     0.8).
  123synonym(larger,    greater,     0.5).
  124synonym(larger,    higher,      0.5).
  125synonym(load,      compile,     0.3).
  126synonym(lock,      mutex,	0.5).
  127synonym(log,       logarithmic, 0.9).
  128synonym(max,       maximum,     0.8).
  129synonym(min,       minimum,     0.5).
  130synonym(min,       minus,       0.5).
  131synonym(mod,	   module,      0.3).
  132synonym(mod,	   modulo,      0.3).
  133synonym(mul,       multiply,	0.5).
  134synonym(param,     parameter,	0.8).
  135synonym(perm,      permutation, 0.5).
  136synonym(pred,      predicate,   0.7).
  137synonym(predicate, procedure,   0.8).
  138synonym(quit,      halt,        0.9).
  139synonym(rand,      random,      0.5).
  140synonym(real,      float,       0.3).
  141synonym(rem,       remainder,   0.3).
  142synonym(remove,    abolish,     0.5).
  143synonym(remove,    retract,     0.5).
  144synonym(remove,    unload,      0.3).
  145synonym(rm,        remove,	0.7).
  146synonym(run,       call,        0.3).
  147synonym(same,      equivalent,  0.8).
  148synonym(screen,    console,     0.5).
  149synonym(semincolon,disjunction, 0.3).
  150synonym(sin,       sine,        0.9).
  151synonym(size,      memory,      0.3).
  152synonym(smaller,   less,        0.5).
  153synonym(smaller,   lower,       0.5).
  154synonym(sqrt,      root,        0.5).
  155synonym(sqrt,      square,      0.5).
  156synonym(ssl,       tls,         0.9).
  157synonym(tan,       tangent,     0.9).
  158synonym(task,	   process,     0.3).
  159synonym(task,	   thread,      0.3).
  160synonym(temp,      temporary,   0.7).
  161synonym(tmp,       temporary,   0.7).
  162synonym(tty,	   terminal,    0.7).
  163synonym(unzip,     decompress,  0.3).
  164synonym(zip,	   compress,    0.3).
  165
  166:- dynamic
  167    prolog_id_part_cached/0,
  168    cached_prolog_id_part/1.
 prolog_identifier_part(?Part) is nondet
True if Part appears as part of a Prolog identifier from the documentation. This extracts most of the Prolog jargon.
  175prolog_identifier_part(Part) :-
  176    prolog_id_part_cached,
  177    !,
  178    cached_prolog_id_part(Part).
  179prolog_identifier_part(Part) :-
  180    with_mutex(doc_search,
  181               make_prolog_id_part_cache),
  182    cached_prolog_id_part(Part).
  183
  184make_prolog_id_part_cache :-
  185    prolog_id_part_cached,
  186    !.
  187make_prolog_id_part_cache :-
  188    findall(Part, prolog_id_part_no_cache(Part), Parts),
  189    sort(Parts, Unique),
  190    forall(member(U, Unique),
  191           assertz(cached_prolog_id_part(U))),
  192    asserta(prolog_id_part_cached).
  193
  194prolog_id_part_no_cache(Part) :-
  195    prolog:doc_object_summary(Obj, _, _, _),
  196    doc_object_identifier(Obj, Identifier),
  197    identifier_parts(Identifier, Parts),
  198    member(Part, Parts)