kibi-swipl-linux-x64-gnu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/bin/swipl +0 -0
- package/bin/swipl-win +0 -0
- package/build-manifest.json +70 -0
- package/lib/cmake/swipl/SWIPLConfig.cmake +21 -0
- package/lib/cmake/swipl/SWIPLConfigVersion.cmake +65 -0
- package/lib/cmake/swipl/SWIPLTargets-release.cmake +28 -0
- package/lib/cmake/swipl/SWIPLTargets.cmake +109 -0
- package/lib/swipl/ABI +1 -0
- package/lib/swipl/LICENSE +41 -0
- package/lib/swipl/README.md +116 -0
- package/lib/swipl/app/README.md +25 -0
- package/lib/swipl/app/app.pl +87 -0
- package/lib/swipl/app/pack.pl +350 -0
- package/lib/swipl/app/qlf.pl +521 -0
- package/lib/swipl/app/splfr.pl +177 -0
- package/lib/swipl/app/sys.pl +310 -0
- package/lib/swipl/bin/swipl.home +1 -0
- package/lib/swipl/boot/apply.pl +73 -0
- package/lib/swipl/boot/attvar.pl +344 -0
- package/lib/swipl/boot/autoload.pl +1226 -0
- package/lib/swipl/boot/bags.pl +283 -0
- package/lib/swipl/boot/dcg.pl +388 -0
- package/lib/swipl/boot/dicts.pl +193 -0
- package/lib/swipl/boot/dwim.pl +485 -0
- package/lib/swipl/boot/engines.pl +152 -0
- package/lib/swipl/boot/expand.pl +1628 -0
- package/lib/swipl/boot/gc.pl +65 -0
- package/lib/swipl/boot/history.pl +304 -0
- package/lib/swipl/boot/init.pl +4682 -0
- package/lib/swipl/boot/iri.pl +64 -0
- package/lib/swipl/boot/license.pl +390 -0
- package/lib/swipl/boot/load.pl +81 -0
- package/lib/swipl/boot/messages.pl +2521 -0
- package/lib/swipl/boot/packs.pl +306 -0
- package/lib/swipl/boot/predopts.pl +154 -0
- package/lib/swipl/boot/qlf.pl +141 -0
- package/lib/swipl/boot/rc.pl +263 -0
- package/lib/swipl/boot/syspred.pl +1634 -0
- package/lib/swipl/boot/tabling.pl +2321 -0
- package/lib/swipl/boot/threads.pl +42 -0
- package/lib/swipl/boot/toplevel.pl +2248 -0
- package/lib/swipl/boot/topvars.pl +261 -0
- package/lib/swipl/boot.prc +0 -0
- package/lib/swipl/cmake/swipl.cmake +131 -0
- package/lib/swipl/customize/README.md +23 -0
- package/lib/swipl/customize/edit +101 -0
- package/lib/swipl/customize/init.pl +164 -0
- package/lib/swipl/demo/README.md +33 -0
- package/lib/swipl/demo/likes.pl +44 -0
- package/lib/swipl/doc/packages/examples/chr/bool.chr +281 -0
- package/lib/swipl/doc/packages/examples/chr/chrdif.chr +87 -0
- package/lib/swipl/doc/packages/examples/chr/chrfreeze.chr +6 -0
- package/lib/swipl/doc/packages/examples/chr/family.chr +116 -0
- package/lib/swipl/doc/packages/examples/chr/fib.chr +24 -0
- package/lib/swipl/doc/packages/examples/chr/fibonacci.chr +31 -0
- package/lib/swipl/doc/packages/examples/chr/gcd.chr +28 -0
- package/lib/swipl/doc/packages/examples/chr/leq.chr +34 -0
- package/lib/swipl/doc/packages/examples/chr/listdom.chr +138 -0
- package/lib/swipl/doc/packages/examples/chr/primes.chr +29 -0
- package/lib/swipl/doc/packages/examples/http/README.md +98 -0
- package/lib/swipl/doc/packages/examples/http/calc.pl +92 -0
- package/lib/swipl/doc/packages/examples/http/demo_body.pl +232 -0
- package/lib/swipl/doc/packages/examples/http/demo_client.pl +165 -0
- package/lib/swipl/doc/packages/examples/http/demo_daemon.pl +38 -0
- package/lib/swipl/doc/packages/examples/http/demo_files.pl +50 -0
- package/lib/swipl/doc/packages/examples/http/demo_hello.pl +15 -0
- package/lib/swipl/doc/packages/examples/http/demo_login.pl +280 -0
- package/lib/swipl/doc/packages/examples/http/demo_openid.pl +177 -0
- package/lib/swipl/doc/packages/examples/http/demo_pwp.pl +20 -0
- package/lib/swipl/doc/packages/examples/http/demo_rest.pl +56 -0
- package/lib/swipl/doc/packages/examples/http/demo_threads.pl +52 -0
- package/lib/swipl/doc/packages/examples/http/linux-init-script +126 -0
- package/lib/swipl/doc/packages/examples/http/pwp/context.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/index.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp1.pwp +12 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp2.pwp +10 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp3.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp4.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp5.pwp +11 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp6.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp7.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp8.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwpdb.pl +12 -0
- package/lib/swipl/doc/packages/examples/http/systemd-script.service +18 -0
- package/lib/swipl/doc/packages/examples/http/upstart-script.conf +20 -0
- package/lib/swipl/doc/packages/examples/plunit/read.pl +17 -0
- package/lib/swipl/doc/packages/examples/plunit/simple.pl +33 -0
- package/lib/swipl/doc/packages/examples/ssl/client.pl +83 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/README +52 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.p12 +0 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/cacert.pem +82 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/careq.pem +18 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/crlnumber +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt +3 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt.attr +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7C.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7D.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/private/cakey.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/serial +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/https.pl +267 -0
- package/lib/swipl/doc/packages/examples/ssl/server.pl +106 -0
- package/lib/swipl/include/SWI-Prolog.h +1544 -0
- package/lib/swipl/include/SWI-Stream.h +537 -0
- package/lib/swipl/include/Yap/YapInterface.h +283 -0
- package/lib/swipl/include/sicstus/sicstus.h +452 -0
- package/lib/swipl/lib/x86_64-linux/cgi.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypt.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypto4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/double_metaphone.so +0 -0
- package/lib/swipl/lib/x86_64-linux/files.so +0 -0
- package/lib/swipl/lib/x86_64-linux/hashstream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/http_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/isub.so +0 -0
- package/lib/swipl/lib/x86_64-linux/json.so +0 -0
- package/lib/swipl/lib/x86_64-linux/libswipl.so.10 +0 -0
- package/lib/swipl/lib/x86_64-linux/mallocinfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/md54pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/memfile.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ntriples.so +0 -0
- package/lib/swipl/lib/x86_64-linux/pcre4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/porter_stem.so +0 -0
- package/lib/swipl/lib/x86_64-linux/process.so +0 -0
- package/lib/swipl/lib/x86_64-linux/prolog_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rdf_db.so +0 -0
- package/lib/swipl/lib/x86_64-linux/readutil.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rlimit.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sched.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sgml2pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sha4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/snowball.so +0 -0
- package/lib/swipl/lib/x86_64-linux/socket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ssl4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/streaminfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/syslog.so +0 -0
- package/lib/swipl/lib/x86_64-linux/time.so +0 -0
- package/lib/swipl/lib/x86_64-linux/turtle.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uid.so +0 -0
- package/lib/swipl/lib/x86_64-linux/unix.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uri.so +0 -0
- package/lib/swipl/lib/x86_64-linux/websocket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/zlib4pl.so +0 -0
- package/lib/swipl/library/INDEX.pl +1020 -0
- package/lib/swipl/library/aggregate.pl +755 -0
- package/lib/swipl/library/ansi_term.pl +653 -0
- package/lib/swipl/library/apply.pl +426 -0
- package/lib/swipl/library/apply_macros.pl +497 -0
- package/lib/swipl/library/arithmetic.pl +320 -0
- package/lib/swipl/library/assoc.pl +522 -0
- package/lib/swipl/library/atom.pl +169 -0
- package/lib/swipl/library/backcomp.pl +688 -0
- package/lib/swipl/library/base32.pl +291 -0
- package/lib/swipl/library/base64.pl +441 -0
- package/lib/swipl/library/broadcast.pl +161 -0
- package/lib/swipl/library/build/cmake.pl +137 -0
- package/lib/swipl/library/build/conan.pl +232 -0
- package/lib/swipl/library/build/make.pl +168 -0
- package/lib/swipl/library/build/tools.pl +825 -0
- package/lib/swipl/library/charsio.pl +195 -0
- package/lib/swipl/library/check.pl +1097 -0
- package/lib/swipl/library/check_installation.pl +912 -0
- package/lib/swipl/library/clp/INDEX.pl +157 -0
- package/lib/swipl/library/clp/bounds.pl +2036 -0
- package/lib/swipl/library/clp/clp_distinct.pl +263 -0
- package/lib/swipl/library/clp/clp_events.pl +92 -0
- package/lib/swipl/library/clp/clpb.pl +1896 -0
- package/lib/swipl/library/clp/clpfd.pl +7906 -0
- package/lib/swipl/library/clp/simplex.pl +1580 -0
- package/lib/swipl/library/codesio.pl +182 -0
- package/lib/swipl/library/coinduction.pl +183 -0
- package/lib/swipl/library/console_input.pl +289 -0
- package/lib/swipl/library/csv.pl +611 -0
- package/lib/swipl/library/ctypes.pl +161 -0
- package/lib/swipl/library/date.pl +370 -0
- package/lib/swipl/library/dcg/INDEX.pl +35 -0
- package/lib/swipl/library/dcg/basics.pl +514 -0
- package/lib/swipl/library/dcg/high_order.pl +227 -0
- package/lib/swipl/library/debug.pl +499 -0
- package/lib/swipl/library/dialect/bim.pl +186 -0
- package/lib/swipl/library/dialect/commons.pl +77 -0
- package/lib/swipl/library/dialect/eclipse/test_util_iso.pl +355 -0
- package/lib/swipl/library/dialect/hprolog/format.pl +44 -0
- package/lib/swipl/library/dialect/hprolog.pl +314 -0
- package/lib/swipl/library/dialect/ifprolog.pl +1317 -0
- package/lib/swipl/library/dialect/iso/iso_predicates.pl +277 -0
- package/lib/swipl/library/dialect/sicstus/README.TXT +1 -0
- package/lib/swipl/library/dialect/sicstus/arrays.pl +121 -0
- package/lib/swipl/library/dialect/sicstus/block.pl +278 -0
- package/lib/swipl/library/dialect/sicstus/lists.pl +167 -0
- package/lib/swipl/library/dialect/sicstus/ordsets.pl +52 -0
- package/lib/swipl/library/dialect/sicstus/sockets.pl +174 -0
- package/lib/swipl/library/dialect/sicstus/system.pl +262 -0
- package/lib/swipl/library/dialect/sicstus/terms.pl +57 -0
- package/lib/swipl/library/dialect/sicstus/timeout.pl +92 -0
- package/lib/swipl/library/dialect/sicstus.pl +582 -0
- package/lib/swipl/library/dialect/sicstus4/aggregate.pl +60 -0
- package/lib/swipl/library/dialect/sicstus4/between.pl +62 -0
- package/lib/swipl/library/dialect/sicstus4/clpfd.pl +75 -0
- package/lib/swipl/library/dialect/sicstus4/file_systems.pl +413 -0
- package/lib/swipl/library/dialect/sicstus4/lists.pl +274 -0
- package/lib/swipl/library/dialect/sicstus4/ordsets.pl +54 -0
- package/lib/swipl/library/dialect/sicstus4/samsort.pl +86 -0
- package/lib/swipl/library/dialect/sicstus4/sets.pl +124 -0
- package/lib/swipl/library/dialect/sicstus4/sockets.pl +164 -0
- package/lib/swipl/library/dialect/sicstus4/system.pl +80 -0
- package/lib/swipl/library/dialect/sicstus4/terms.pl +89 -0
- package/lib/swipl/library/dialect/sicstus4/timeout.pl +43 -0
- package/lib/swipl/library/dialect/sicstus4/types.pl +103 -0
- package/lib/swipl/library/dialect/sicstus4.pl +200 -0
- package/lib/swipl/library/dialect/swi/syspred_options.pl +250 -0
- package/lib/swipl/library/dialect/xsb/README.md +20 -0
- package/lib/swipl/library/dialect/xsb/basics.pl +318 -0
- package/lib/swipl/library/dialect/xsb/consult.pl +87 -0
- package/lib/swipl/library/dialect/xsb/curr_sym.pl +57 -0
- package/lib/swipl/library/dialect/xsb/error_handler.pl +111 -0
- package/lib/swipl/library/dialect/xsb/gensym.pl +53 -0
- package/lib/swipl/library/dialect/xsb/gpp.pl +138 -0
- package/lib/swipl/library/dialect/xsb/intern.pl +48 -0
- package/lib/swipl/library/dialect/xsb/lists.pl +47 -0
- package/lib/swipl/library/dialect/xsb/machine.pl +295 -0
- package/lib/swipl/library/dialect/xsb/ordsets.pl +53 -0
- package/lib/swipl/library/dialect/xsb/setof.pl +54 -0
- package/lib/swipl/library/dialect/xsb/source.pl +308 -0
- package/lib/swipl/library/dialect/xsb/standard.pl +169 -0
- package/lib/swipl/library/dialect/xsb/storage.pl +70 -0
- package/lib/swipl/library/dialect/xsb/string.pl +76 -0
- package/lib/swipl/library/dialect/xsb/thread.pl +62 -0
- package/lib/swipl/library/dialect/xsb/timed_call.pl +158 -0
- package/lib/swipl/library/dialect/xsb.pl +688 -0
- package/lib/swipl/library/dialect/yap/README.TXT +8 -0
- package/lib/swipl/library/dialect/yap.pl +283 -0
- package/lib/swipl/library/dialect.pl +123 -0
- package/lib/swipl/library/dicts.pl +399 -0
- package/lib/swipl/library/dif.pl +426 -0
- package/lib/swipl/library/edinburgh.pl +138 -0
- package/lib/swipl/library/edit.pl +783 -0
- package/lib/swipl/library/error.pl +495 -0
- package/lib/swipl/library/exceptions.pl +231 -0
- package/lib/swipl/library/explain.pl +543 -0
- package/lib/swipl/library/ext/RDF/INDEX.pl +25 -0
- package/lib/swipl/library/ext/RDF/rdf.pl +450 -0
- package/lib/swipl/library/ext/RDF/rdf_parser.pl +649 -0
- package/lib/swipl/library/ext/RDF/rdf_triple.pl +448 -0
- package/lib/swipl/library/ext/RDF/rdf_write.pl +701 -0
- package/lib/swipl/library/ext/RDF/rewrite_term.pl +177 -0
- package/lib/swipl/library/ext/chr/chr/a_star.pl +80 -0
- package/lib/swipl/library/ext/chr/chr/binomialheap.pl +142 -0
- package/lib/swipl/library/ext/chr/chr/builtins.pl +629 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_errors.pl +179 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_options.pl +382 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_utility.pl +338 -0
- package/lib/swipl/library/ext/chr/chr/chr_debug.pl +59 -0
- package/lib/swipl/library/ext/chr/chr/chr_hashtable_store.pl +425 -0
- package/lib/swipl/library/ext/chr/chr/chr_integertable_store.pl +139 -0
- package/lib/swipl/library/ext/chr/chr/chr_messages.pl +176 -0
- package/lib/swipl/library/ext/chr/chr/chr_op.pl +53 -0
- package/lib/swipl/library/ext/chr/chr/chr_runtime.pl +1016 -0
- package/lib/swipl/library/ext/chr/chr/chr_translate.pl +25424 -0
- package/lib/swipl/library/ext/chr/chr/clean_code.pl +252 -0
- package/lib/swipl/library/ext/chr/chr/find.pl +78 -0
- package/lib/swipl/library/ext/chr/chr/guard_entailment.pl +19432 -0
- package/lib/swipl/library/ext/chr/chr/listmap.pl +108 -0
- package/lib/swipl/library/ext/chr/chr/pairlist.pl +78 -0
- package/lib/swipl/library/ext/chr/chr.pl +686 -0
- package/lib/swipl/library/ext/clib/INDEX.pl +158 -0
- package/lib/swipl/library/ext/clib/cgi.pl +86 -0
- package/lib/swipl/library/ext/clib/crypt.pl +44 -0
- package/lib/swipl/library/ext/clib/filesex.pl +644 -0
- package/lib/swipl/library/ext/clib/hash_stream.pl +119 -0
- package/lib/swipl/library/ext/clib/mallocinfo.pl +138 -0
- package/lib/swipl/library/ext/clib/md5.pl +68 -0
- package/lib/swipl/library/ext/clib/memfile.pl +61 -0
- package/lib/swipl/library/ext/clib/process.pl +573 -0
- package/lib/swipl/library/ext/clib/prolog_server.pl +157 -0
- package/lib/swipl/library/ext/clib/prolog_stream.pl +80 -0
- package/lib/swipl/library/ext/clib/rlimit.pl +54 -0
- package/lib/swipl/library/ext/clib/sched.pl +85 -0
- package/lib/swipl/library/ext/clib/sha.pl +162 -0
- package/lib/swipl/library/ext/clib/socket.pl +1102 -0
- package/lib/swipl/library/ext/clib/streaminfo.pl +103 -0
- package/lib/swipl/library/ext/clib/streampool.pl +136 -0
- package/lib/swipl/library/ext/clib/syslog.pl +180 -0
- package/lib/swipl/library/ext/clib/time.pl +194 -0
- package/lib/swipl/library/ext/clib/udp_broadcast.pl +975 -0
- package/lib/swipl/library/ext/clib/uid.pl +220 -0
- package/lib/swipl/library/ext/clib/unix.pl +317 -0
- package/lib/swipl/library/ext/clib/uri.pl +530 -0
- package/lib/swipl/library/ext/clib/uuid.pl +207 -0
- package/lib/swipl/library/ext/http/http/INDEX.pl +266 -0
- package/lib/swipl/library/ext/http/http/README.md +34 -0
- package/lib/swipl/library/ext/http/http/ax.pl +189 -0
- package/lib/swipl/library/ext/http/http/dcg_basics.pl +49 -0
- package/lib/swipl/library/ext/http/http/graphql.pl +1367 -0
- package/lib/swipl/library/ext/http/http/html_decl.pl +416 -0
- package/lib/swipl/library/ext/http/http/html_head.pl +654 -0
- package/lib/swipl/library/ext/http/http/html_quasiquotations.pl +120 -0
- package/lib/swipl/library/ext/http/http/html_write.pl +1425 -0
- package/lib/swipl/library/ext/http/http/htmx.pl +139 -0
- package/lib/swipl/library/ext/http/http/http_authenticate.pl +364 -0
- package/lib/swipl/library/ext/http/http/http_client.pl +412 -0
- package/lib/swipl/library/ext/http/http/http_cookie.pl +245 -0
- package/lib/swipl/library/ext/http/http/http_cors.pl +176 -0
- package/lib/swipl/library/ext/http/http/http_digest.pl +820 -0
- package/lib/swipl/library/ext/http/http/http_dirindex.pl +296 -0
- package/lib/swipl/library/ext/http/http/http_dispatch.pl +1552 -0
- package/lib/swipl/library/ext/http/http/http_dyn_workers.pl +214 -0
- package/lib/swipl/library/ext/http/http/http_error.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_exception.pl +225 -0
- package/lib/swipl/library/ext/http/http/http_files.pl +163 -0
- package/lib/swipl/library/ext/http/http/http_header.pl +2820 -0
- package/lib/swipl/library/ext/http/http/http_hook.pl +106 -0
- package/lib/swipl/library/ext/http/http/http_host.pl +204 -0
- package/lib/swipl/library/ext/http/http/http_load.pl +113 -0
- package/lib/swipl/library/ext/http/http/http_log.pl +738 -0
- package/lib/swipl/library/ext/http/http/http_multipart_plugin.pl +232 -0
- package/lib/swipl/library/ext/http/http/http_open.pl +1821 -0
- package/lib/swipl/library/ext/http/http/http_openid.pl +1561 -0
- package/lib/swipl/library/ext/http/http/http_parameters.pl +504 -0
- package/lib/swipl/library/ext/http/http/http_path.pl +380 -0
- package/lib/swipl/library/ext/http/http/http_proxy.pl +80 -0
- package/lib/swipl/library/ext/http/http/http_pwp.pl +351 -0
- package/lib/swipl/library/ext/http/http/http_redis_plugin.pl +332 -0
- package/lib/swipl/library/ext/http/http/http_server.pl +105 -0
- package/lib/swipl/library/ext/http/http/http_server_files.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_server_health.pl +186 -0
- package/lib/swipl/library/ext/http/http/http_session.pl +1040 -0
- package/lib/swipl/library/ext/http/http/http_sgml_plugin.pl +137 -0
- package/lib/swipl/library/ext/http/http/http_stream.pl +376 -0
- package/lib/swipl/library/ext/http/http/http_unix_daemon.pl +989 -0
- package/lib/swipl/library/ext/http/http/http_wrapper.pl +559 -0
- package/lib/swipl/library/ext/http/http/hub.pl +600 -0
- package/lib/swipl/library/ext/http/http/js_write.pl +461 -0
- package/lib/swipl/library/ext/http/http/mimepack.pl +224 -0
- package/lib/swipl/library/ext/http/http/mimetype.pl +276 -0
- package/lib/swipl/library/ext/http/http/term_html.pl +797 -0
- package/lib/swipl/library/ext/http/http/thread_httpd.pl +1181 -0
- package/lib/swipl/library/ext/http/http/web/css/dirindex.css +24 -0
- package/lib/swipl/library/ext/http/http/web/css/openid.css +57 -0
- package/lib/swipl/library/ext/http/http/web/icons/back.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/c.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/compressed.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/folder.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/generic.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/layout.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-square.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-tiny.png +0 -0
- package/lib/swipl/library/ext/http/http/websocket.pl +729 -0
- package/lib/swipl/library/ext/http/http/yadis.pl +205 -0
- package/lib/swipl/library/ext/json/INDEX.pl +36 -0
- package/lib/swipl/library/ext/json/http/INDEX.pl +16 -0
- package/lib/swipl/library/ext/json/http/http_json.pl +490 -0
- package/lib/swipl/library/ext/json/http/js_grammar.pl +53 -0
- package/lib/swipl/library/ext/json/http/json.pl +48 -0
- package/lib/swipl/library/ext/json/http/json_convert.pl +48 -0
- package/lib/swipl/library/ext/json/json.pl +1215 -0
- package/lib/swipl/library/ext/json/json_convert.pl +681 -0
- package/lib/swipl/library/ext/json/json_grammar.pl +349 -0
- package/lib/swipl/library/ext/json/json_rpc_client.pl +423 -0
- package/lib/swipl/library/ext/json/json_rpc_common.pl +104 -0
- package/lib/swipl/library/ext/json/json_rpc_server.pl +489 -0
- package/lib/swipl/library/ext/json/json_schema.pl +2111 -0
- package/lib/swipl/library/ext/nlp/INDEX.pl +15 -0
- package/lib/swipl/library/ext/nlp/double_metaphone.pl +86 -0
- package/lib/swipl/library/ext/nlp/isub.pl +162 -0
- package/lib/swipl/library/ext/nlp/porter_stem.pl +50 -0
- package/lib/swipl/library/ext/nlp/snowball.pl +97 -0
- package/lib/swipl/library/ext/pcre/INDEX.pl +17 -0
- package/lib/swipl/library/ext/pcre/pcre.pl +974 -0
- package/lib/swipl/library/ext/plunit/INDEX.pl +20 -0
- package/lib/swipl/library/ext/plunit/plunit.pl +2631 -0
- package/lib/swipl/library/ext/plunit/test_wizard.pl +249 -0
- package/lib/swipl/library/ext/semweb/semweb/INDEX.pl +288 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11.pl +2106 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11_containers.pl +299 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_cache.pl +278 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_compare.pl +132 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_db.pl +3468 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_edit.pl +1145 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_http_plugin.pl +274 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_library.pl +1021 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_litindex.pl +1035 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_ntriples.pl +422 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_persistency.pl +1576 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_portray.pl +182 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_prefixes.pl +681 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_sandbox.pl +153 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle.pl +54 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle_write.pl +1587 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_zlib_plugin.pl +52 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfa.pl +1510 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfs.pl +475 -0
- package/lib/swipl/library/ext/semweb/semweb/sparql_client.pl +643 -0
- package/lib/swipl/library/ext/semweb/semweb/turtle.pl +455 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dcl +88 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dtd +1092 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.soc +6 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML5.dtd +906 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLlat1.ent +195 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLspec.ent +77 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLsym.ent +241 -0
- package/lib/swipl/library/ext/sgml/INDEX.pl +64 -0
- package/lib/swipl/library/ext/sgml/c14n2.pl +203 -0
- package/lib/swipl/library/ext/sgml/iso_639.pl +631 -0
- package/lib/swipl/library/ext/sgml/pwp.pl +705 -0
- package/lib/swipl/library/ext/sgml/sgml.pl +815 -0
- package/lib/swipl/library/ext/sgml/sgml_write.pl +1003 -0
- package/lib/swipl/library/ext/sgml/xpath.pl +620 -0
- package/lib/swipl/library/ext/sgml/xsdp_types.pl +232 -0
- package/lib/swipl/library/ext/ssl/INDEX.pl +60 -0
- package/lib/swipl/library/ext/ssl/crypto.pl +1015 -0
- package/lib/swipl/library/ext/ssl/http/INDEX.pl +5 -0
- package/lib/swipl/library/ext/ssl/http/http_ssl_plugin.pl +296 -0
- package/lib/swipl/library/ext/ssl/saml.pl +609 -0
- package/lib/swipl/library/ext/ssl/ssl.pl +647 -0
- package/lib/swipl/library/ext/ssl/xmldsig.pl +391 -0
- package/lib/swipl/library/ext/ssl/xmlenc.pl +354 -0
- package/lib/swipl/library/ext/zlib/INDEX.pl +8 -0
- package/lib/swipl/library/ext/zlib/zlib.pl +112 -0
- package/lib/swipl/library/fastrw.pl +105 -0
- package/lib/swipl/library/files.pl +80 -0
- package/lib/swipl/library/gensym.pl +111 -0
- package/lib/swipl/library/git.pl +1027 -0
- package/lib/swipl/library/hashtable.pl +365 -0
- package/lib/swipl/library/heaps.pl +252 -0
- package/lib/swipl/library/hotfix.pl +239 -0
- package/lib/swipl/library/http/jquery.pl +103 -0
- package/lib/swipl/library/http/web/js/jquery-3.6.0.min.js +2 -0
- package/lib/swipl/library/increval.pl +217 -0
- package/lib/swipl/library/intercept.pl +263 -0
- package/lib/swipl/library/iostream.pl +237 -0
- package/lib/swipl/library/iri_scheme/file.pl +70 -0
- package/lib/swipl/library/lazy_lists.pl +481 -0
- package/lib/swipl/library/listing.pl +1362 -0
- package/lib/swipl/library/lists.pl +860 -0
- package/lib/swipl/library/lynx/INDEX.pl +14 -0
- package/lib/swipl/library/lynx/format.pl +380 -0
- package/lib/swipl/library/lynx/html_style.pl +129 -0
- package/lib/swipl/library/lynx/html_text.pl +865 -0
- package/lib/swipl/library/lynx/pldoc_style.pl +87 -0
- package/lib/swipl/library/macros.pl +451 -0
- package/lib/swipl/library/main.pl +1200 -0
- package/lib/swipl/library/make.pl +197 -0
- package/lib/swipl/library/modules.pl +129 -0
- package/lib/swipl/library/nb_rbtrees.pl +267 -0
- package/lib/swipl/library/nb_set.pl +203 -0
- package/lib/swipl/library/obfuscate.pl +115 -0
- package/lib/swipl/library/occurs.pl +241 -0
- package/lib/swipl/library/operators.pl +182 -0
- package/lib/swipl/library/option.pl +388 -0
- package/lib/swipl/library/optparse.pl +966 -0
- package/lib/swipl/library/ordsets.pl +518 -0
- package/lib/swipl/library/oset.pl +160 -0
- package/lib/swipl/library/pairs.pl +187 -0
- package/lib/swipl/library/persistency.pl +713 -0
- package/lib/swipl/library/pio.pl +47 -0
- package/lib/swipl/library/portray_text.pl +277 -0
- package/lib/swipl/library/pprint.pl +940 -0
- package/lib/swipl/library/predicate_options.pl +975 -0
- package/lib/swipl/library/prolog_autoload.pl +233 -0
- package/lib/swipl/library/prolog_breakpoints.pl +396 -0
- package/lib/swipl/library/prolog_clause.pl +1104 -0
- package/lib/swipl/library/prolog_code.pl +416 -0
- package/lib/swipl/library/prolog_codewalk.pl +1248 -0
- package/lib/swipl/library/prolog_colour.pl +3301 -0
- package/lib/swipl/library/prolog_colour.qlf +0 -0
- package/lib/swipl/library/prolog_config.pl +154 -0
- package/lib/swipl/library/prolog_coverage.pl +1333 -0
- package/lib/swipl/library/prolog_debug.pl +404 -0
- package/lib/swipl/library/prolog_deps.pl +675 -0
- package/lib/swipl/library/prolog_evaluable.pl +234 -0
- package/lib/swipl/library/prolog_format.pl +219 -0
- package/lib/swipl/library/prolog_history.pl +161 -0
- package/lib/swipl/library/prolog_jiti.pl +333 -0
- package/lib/swipl/library/prolog_locale.pl +61 -0
- package/lib/swipl/library/prolog_metainference.pl +307 -0
- package/lib/swipl/library/prolog_pack.pl +3906 -0
- package/lib/swipl/library/prolog_profile.pl +346 -0
- package/lib/swipl/library/prolog_qlfmake.pl +533 -0
- package/lib/swipl/library/prolog_source.pl +1188 -0
- package/lib/swipl/library/prolog_stack.pl +794 -0
- package/lib/swipl/library/prolog_trace.pl +365 -0
- package/lib/swipl/library/prolog_versions.pl +347 -0
- package/lib/swipl/library/prolog_wrap.pl +164 -0
- package/lib/swipl/library/prolog_xref.pl +3090 -0
- package/lib/swipl/library/prolog_xref.qlf +0 -0
- package/lib/swipl/library/pure_input.pl +266 -0
- package/lib/swipl/library/qpforeign.pl +695 -0
- package/lib/swipl/library/qsave.pl +1516 -0
- package/lib/swipl/library/quasi_quotations.pl +300 -0
- package/lib/swipl/library/quintus.pl +437 -0
- package/lib/swipl/library/random.pl +459 -0
- package/lib/swipl/library/rbtrees.pl +1153 -0
- package/lib/swipl/library/readln.pl +256 -0
- package/lib/swipl/library/readutil.pl +304 -0
- package/lib/swipl/library/record.pl +544 -0
- package/lib/swipl/library/rwlocks.pl +172 -0
- package/lib/swipl/library/sandbox.pl +1384 -0
- package/lib/swipl/library/semweb/dc.rdfs +198 -0
- package/lib/swipl/library/semweb/eor.rdfs +95 -0
- package/lib/swipl/library/semweb/owl.owl +287 -0
- package/lib/swipl/library/semweb/rdf_library.ttl +90 -0
- package/lib/swipl/library/semweb/rdfs.rdfs +251 -0
- package/lib/swipl/library/settings.pl +755 -0
- package/lib/swipl/library/shell.pl +462 -0
- package/lib/swipl/library/shlib.pl +670 -0
- package/lib/swipl/library/solution_sequences.pl +439 -0
- package/lib/swipl/library/sort.pl +119 -0
- package/lib/swipl/library/statistics.pl +541 -0
- package/lib/swipl/library/streams.pl +118 -0
- package/lib/swipl/library/strings.pl +469 -0
- package/lib/swipl/library/system.pl +95 -0
- package/lib/swipl/library/tables.pl +381 -0
- package/lib/swipl/library/tableutil.pl +771 -0
- package/lib/swipl/library/tabling.pl +42 -0
- package/lib/swipl/library/terms.pl +457 -0
- package/lib/swipl/library/theme/auto.pl +61 -0
- package/lib/swipl/library/theme/dark.pl +455 -0
- package/lib/swipl/library/theme/light.pl +45 -0
- package/lib/swipl/library/thread.pl +810 -0
- package/lib/swipl/library/thread_pool.pl +508 -0
- package/lib/swipl/library/threadutil.pl +574 -0
- package/lib/swipl/library/tty.pl +316 -0
- package/lib/swipl/library/ugraphs.pl +644 -0
- package/lib/swipl/library/unicode/INDEX.pl +6 -0
- package/lib/swipl/library/unicode/blocks.pl +414 -0
- package/lib/swipl/library/url.pl +1129 -0
- package/lib/swipl/library/utf8.pl +145 -0
- package/lib/swipl/library/varnumbers.pl +221 -0
- package/lib/swipl/library/vm.pl +251 -0
- package/lib/swipl/library/wfs.pl +205 -0
- package/lib/swipl/library/when.pl +263 -0
- package/lib/swipl/library/writef.pl +278 -0
- package/lib/swipl/library/www_browser.pl +251 -0
- package/lib/swipl/library/yall.pl +574 -0
- package/lib/swipl/library/zip.pl +211 -0
- package/lib/swipl/swipl.home +1 -0
- package/lib/vendor/libcrypto.so.3 +0 -0
- package/lib/vendor/libpcre2-8.so.0 +0 -0
- package/lib/vendor/libssl.so.3 +0 -0
- package/lib/vendor/libz.so.1 +0 -0
- package/licenses/OpenSSL-LICENSE.txt +177 -0
- package/licenses/PCRE2-COPYING +5 -0
- package/licenses/README.md +12 -0
- package/licenses/SWI-Prolog-LICENSE +41 -0
- package/licenses/zlib-LICENSE +22 -0
- package/package.json +27 -0
|
@@ -0,0 +1,1035 @@
|
|
|
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) 2006-2020, University of Amsterdam
|
|
7
|
+
VU University Amsterdam
|
|
8
|
+
CWI, Amsterdam
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
|
12
|
+
modification, are permitted provided that the following conditions
|
|
13
|
+
are met:
|
|
14
|
+
|
|
15
|
+
1. Redistributions of source code must retain the above copyright
|
|
16
|
+
notice, this list of conditions and the following disclaimer.
|
|
17
|
+
|
|
18
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
19
|
+
notice, this list of conditions and the following disclaimer in
|
|
20
|
+
the documentation and/or other materials provided with the
|
|
21
|
+
distribution.
|
|
22
|
+
|
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
24
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
25
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
26
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
27
|
+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
28
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
29
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
30
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
31
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
32
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
33
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
34
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
:- module(rdf_litindex,
|
|
38
|
+
[ rdf_set_literal_index_option/1, % +Options
|
|
39
|
+
rdf_tokenize_literal/2, % +Literal, -Tokens
|
|
40
|
+
rdf_find_literal/2, % +Spec, -Literal
|
|
41
|
+
rdf_find_literals/2, % +Spec, -ListOfLiterals
|
|
42
|
+
rdf_token_expansions/2, % +Spec, -Expansions
|
|
43
|
+
rdf_stopgap_token/1, % -Token
|
|
44
|
+
|
|
45
|
+
rdf_literal_index/2, % +Type, -Index
|
|
46
|
+
rdf_delete_literal_index/1 % +Type
|
|
47
|
+
]).
|
|
48
|
+
:- autoload(rdf_db,
|
|
49
|
+
[ rdf_keys_in_literal_map/3,
|
|
50
|
+
rdf_find_literal_map/3,
|
|
51
|
+
rdf_new_literal_map/1,
|
|
52
|
+
rdf_monitor/2,
|
|
53
|
+
rdf_current_literal/1,
|
|
54
|
+
rdf_reset_literal_map/1,
|
|
55
|
+
rdf_insert_literal_map/4,
|
|
56
|
+
rdf_delete_literal_map/2,
|
|
57
|
+
rdf/3,
|
|
58
|
+
rdf_delete_literal_map/3,
|
|
59
|
+
rdf_insert_literal_map/3,
|
|
60
|
+
rdf_statistics_literal_map/2
|
|
61
|
+
]).
|
|
62
|
+
:- autoload(library(apply),[maplist/3]).
|
|
63
|
+
:- use_module(library(debug),[debug/3]).
|
|
64
|
+
:- autoload(library(double_metaphone),[double_metaphone/2]).
|
|
65
|
+
:- autoload(library(error),
|
|
66
|
+
[instantiation_error/1,must_be/2,domain_error/2]).
|
|
67
|
+
:- autoload(library(lists),[member/2,flatten/2,append/3]).
|
|
68
|
+
:- autoload(library(porter_stem),[tokenize_atom/2]).
|
|
69
|
+
:- autoload(library(snowball),[snowball/3]).
|
|
70
|
+
|
|
71
|
+
/** <module> Search literals
|
|
72
|
+
|
|
73
|
+
This module finds literals of the RDF database based on words, stemming
|
|
74
|
+
and _sounds like_ (metaphone). The normal user-level predicate is
|
|
75
|
+
|
|
76
|
+
- rdf_find_literals/2
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
:- dynamic
|
|
80
|
+
literal_map/2, % Type, -Map
|
|
81
|
+
map_building/2, % Type, -Queue
|
|
82
|
+
new_token/2, % Hook
|
|
83
|
+
setting/1,
|
|
84
|
+
stopgap/1.
|
|
85
|
+
:- volatile
|
|
86
|
+
literal_map/2.
|
|
87
|
+
:- multifile
|
|
88
|
+
tokenization/2, % +Literal, -Tokens
|
|
89
|
+
exclude_from_index/2. % +Which, +Token
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
setting(verbose(false)). % print progress messages
|
|
93
|
+
setting(index_threads(1)). % # threads for creating the index
|
|
94
|
+
setting(index(thread(1))). % Use a thread for incremental updates
|
|
95
|
+
setting(stopgap_threshold(50000)). % consider token a stopgap over N
|
|
96
|
+
|
|
97
|
+
%! rdf_set_literal_index_option(+Options:list)
|
|
98
|
+
%
|
|
99
|
+
% Set options for the literal package. Currently defined options
|
|
100
|
+
%
|
|
101
|
+
% * verbose(Bool)
|
|
102
|
+
% If =true=, print progress messages while building the
|
|
103
|
+
% index tables.
|
|
104
|
+
%
|
|
105
|
+
% * index_threads(+Count)
|
|
106
|
+
% Number of threads to use for initial indexing of
|
|
107
|
+
% literals
|
|
108
|
+
%
|
|
109
|
+
% * index(+How)
|
|
110
|
+
% How to deal with indexing new literals. How is one of
|
|
111
|
+
% =self= (execute in the same thread), thread(N) (execute
|
|
112
|
+
% in N concurrent threads) or =default= (depends on number
|
|
113
|
+
% of cores).
|
|
114
|
+
%
|
|
115
|
+
% * stopgap_threshold(+Count)
|
|
116
|
+
% Add a token to the dynamic stopgap set if it appears in
|
|
117
|
+
% more than Count literals. The default is 50,000.
|
|
118
|
+
|
|
119
|
+
rdf_set_literal_index_option([]) :- !.
|
|
120
|
+
rdf_set_literal_index_option([H|T]) :-
|
|
121
|
+
!,
|
|
122
|
+
set_option(H),
|
|
123
|
+
rdf_set_literal_index_option(T).
|
|
124
|
+
rdf_set_literal_index_option(Option) :-
|
|
125
|
+
set_option(Option).
|
|
126
|
+
|
|
127
|
+
set_option(Term) :-
|
|
128
|
+
check_option(Term),
|
|
129
|
+
functor(Term, Name, Arity),
|
|
130
|
+
functor(General, Name, Arity),
|
|
131
|
+
retractall(setting(General)),
|
|
132
|
+
assert(setting(Term)).
|
|
133
|
+
|
|
134
|
+
check_option(X) :-
|
|
135
|
+
var(X),
|
|
136
|
+
!,
|
|
137
|
+
instantiation_error(X).
|
|
138
|
+
check_option(verbose(X)) :-
|
|
139
|
+
!,
|
|
140
|
+
must_be(boolean, X).
|
|
141
|
+
check_option(index_threads(Count)) :-
|
|
142
|
+
!,
|
|
143
|
+
must_be(nonneg, Count).
|
|
144
|
+
check_option(stopgap_threshold(Count)) :-
|
|
145
|
+
!,
|
|
146
|
+
must_be(nonneg, Count).
|
|
147
|
+
check_option(index(How)) :-
|
|
148
|
+
!,
|
|
149
|
+
must_be(oneof([default,thread(_),self]), How).
|
|
150
|
+
check_option(Option) :-
|
|
151
|
+
domain_error(literal_option, Option).
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
/*******************************
|
|
155
|
+
* QUERY *
|
|
156
|
+
*******************************/
|
|
157
|
+
|
|
158
|
+
%! rdf_find_literal(+Spec, -Literal) is nondet.
|
|
159
|
+
%! rdf_find_literals(+Spec, -Literals) is det.
|
|
160
|
+
%
|
|
161
|
+
% Find literals in the RDF database matching Spec. Spec is defined
|
|
162
|
+
% as:
|
|
163
|
+
%
|
|
164
|
+
% ==
|
|
165
|
+
% Spec ::= and(Spec,Spec)
|
|
166
|
+
% Spec ::= or(Spec,Spec)
|
|
167
|
+
% Spec ::= not(Spec)
|
|
168
|
+
% Spec ::= sounds(Like)
|
|
169
|
+
% Spec ::= stem(Like) % same as stem(Like, en)
|
|
170
|
+
% Spec ::= stem(Like, Lang)
|
|
171
|
+
% Spec ::= prefix(Prefix)
|
|
172
|
+
% Spec ::= between(Low, High) % Numerical between
|
|
173
|
+
% Spec ::= ge(High) % Numerical greater-equal
|
|
174
|
+
% Spec ::= le(Low) % Numerical less-equal
|
|
175
|
+
% Spec ::= Token
|
|
176
|
+
% ==
|
|
177
|
+
%
|
|
178
|
+
% sounds(Like) and stem(Like) both map to a disjunction. First we
|
|
179
|
+
% compile the spec to normal form: a disjunction of conjunctions
|
|
180
|
+
% on elementary tokens. Then we execute all the conjunctions and
|
|
181
|
+
% generate the union using ordered-set algorithms.
|
|
182
|
+
%
|
|
183
|
+
% Stopgaps are ignored. If the final result is only a stopgap, the
|
|
184
|
+
% predicate fails.
|
|
185
|
+
%
|
|
186
|
+
% @tbd Exploit ordering of numbers and allow for > N, < N, etc.
|
|
187
|
+
|
|
188
|
+
rdf_find_literal(Spec, Literal) :-
|
|
189
|
+
rdf_find_literals(Spec, Literals),
|
|
190
|
+
member(Literal, Literals).
|
|
191
|
+
|
|
192
|
+
rdf_find_literals(Spec, Literals) :-
|
|
193
|
+
compile_spec(Spec, DNF),
|
|
194
|
+
DNF \== @(stopgap),
|
|
195
|
+
token_index(Map),
|
|
196
|
+
lookup(DNF, Map, _, SuperSet),
|
|
197
|
+
flatten(SuperSet, Set0),
|
|
198
|
+
sort(Set0, Literals).
|
|
199
|
+
|
|
200
|
+
%! rdf_token_expansions(+Spec, -Extensions)
|
|
201
|
+
%
|
|
202
|
+
% Determine which extensions of a token contribute to finding
|
|
203
|
+
% literals.
|
|
204
|
+
|
|
205
|
+
rdf_token_expansions(prefix(Prefix), [prefix(Prefix, Tokens)]) :-
|
|
206
|
+
token_index(Map),
|
|
207
|
+
rdf_keys_in_literal_map(Map, prefix(Prefix), Tokens).
|
|
208
|
+
rdf_token_expansions(sounds(Like), [sounds(Like, Tokens)]) :-
|
|
209
|
+
metaphone_index(Map),
|
|
210
|
+
rdf_find_literal_map(Map, [Like], Tokens).
|
|
211
|
+
rdf_token_expansions(stem(Like), [stem(Like, Tokens)]) :-
|
|
212
|
+
stem_index(Map),
|
|
213
|
+
rdf_find_literal_map(Map, [Like], Tokens).
|
|
214
|
+
rdf_token_expansions(Spec, Expansions) :-
|
|
215
|
+
compile_spec(Spec, DNF),
|
|
216
|
+
token_index(Map),
|
|
217
|
+
lookup(DNF, Map, SCS, _),
|
|
218
|
+
flatten(SCS, CS),
|
|
219
|
+
sort(CS, Expansions0),
|
|
220
|
+
join_expansions(Expansions0, Expansions).
|
|
221
|
+
|
|
222
|
+
join_expansions([], []).
|
|
223
|
+
join_expansions([H0|T0], [H|T]) :-
|
|
224
|
+
untag(H0, Tag, V0),
|
|
225
|
+
Tag =.. L0,
|
|
226
|
+
append(L0, [[V0|Values]], L1),
|
|
227
|
+
H =.. L1,
|
|
228
|
+
join_expansions_by_tag(T0, Tag, T1, Values),
|
|
229
|
+
join_expansions(T1, T).
|
|
230
|
+
|
|
231
|
+
join_expansions_by_tag([H|T0], Tag, T, [V0|VT]) :-
|
|
232
|
+
untag(H, Tag, V0),
|
|
233
|
+
!,
|
|
234
|
+
join_expansions_by_tag(T0, Tag, T, VT).
|
|
235
|
+
join_expansions_by_tag(L, _, L, []).
|
|
236
|
+
|
|
237
|
+
lookup(@(false), _, [], []) :- !.
|
|
238
|
+
lookup(or(H0,T0), Map, [CH|CT], [H|T]) :-
|
|
239
|
+
!,
|
|
240
|
+
lookup(H0, Map, CH, H),
|
|
241
|
+
lookup(T0, Map, CT, T).
|
|
242
|
+
lookup(H0, Map, [C], [H]) :-
|
|
243
|
+
lookup1(H0, Map, C, H).
|
|
244
|
+
|
|
245
|
+
lookup1(Conj, Map, Cond, Literals) :-
|
|
246
|
+
phrase(conj_to_list(Conj), List),
|
|
247
|
+
!,
|
|
248
|
+
rdf_find_literal_map(Map, List, Literals),
|
|
249
|
+
( Literals \== []
|
|
250
|
+
-> phrase(conj_to_cond(Conj), Cond)
|
|
251
|
+
; Cond = []
|
|
252
|
+
).
|
|
253
|
+
lookup1(_, _, _, []).
|
|
254
|
+
|
|
255
|
+
conj_to_list(and(A,B)) -->
|
|
256
|
+
!,
|
|
257
|
+
conj_to_list(A),
|
|
258
|
+
conj_to_list(B).
|
|
259
|
+
conj_to_list(@(false)) -->
|
|
260
|
+
!,
|
|
261
|
+
{fail}.
|
|
262
|
+
conj_to_list(Tagged) -->
|
|
263
|
+
{ untag(Tagged, L) },
|
|
264
|
+
!,
|
|
265
|
+
[L].
|
|
266
|
+
conj_to_list(L) -->
|
|
267
|
+
[L].
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
conj_to_cond(and(A,B)) -->
|
|
271
|
+
!,
|
|
272
|
+
conj_to_cond(A),
|
|
273
|
+
conj_to_cond(B).
|
|
274
|
+
conj_to_cond(Tagged) -->
|
|
275
|
+
{ untag(Tagged, _) },
|
|
276
|
+
!,
|
|
277
|
+
[ Tagged ].
|
|
278
|
+
conj_to_cond(_) -->
|
|
279
|
+
[].
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
%! compile_spec(+Spec, -Compiled)
|
|
283
|
+
%
|
|
284
|
+
% Compile a specification as above into disjunctive normal form
|
|
285
|
+
|
|
286
|
+
compile_spec(Spec, DNF) :-
|
|
287
|
+
expand_fuzzy(Spec, Spec2),
|
|
288
|
+
nnf(Spec2, NNF),
|
|
289
|
+
dnf(NNF, DNF).
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
expand_fuzzy(Var, _) :-
|
|
293
|
+
var(Var),
|
|
294
|
+
!,
|
|
295
|
+
throw(error(instantiation_error, _)).
|
|
296
|
+
expand_fuzzy(sounds(Like), Or) :-
|
|
297
|
+
!,
|
|
298
|
+
( atom(Like)
|
|
299
|
+
-> metaphone_index(Map),
|
|
300
|
+
double_metaphone(Like, Key),
|
|
301
|
+
rdf_find_literal_map(Map, [Key], Tokens),
|
|
302
|
+
list_to_or(Tokens, sounds(Like), Or)
|
|
303
|
+
; expand_fuzzy(Like, Or)
|
|
304
|
+
).
|
|
305
|
+
expand_fuzzy(stem(Like), Or) :-
|
|
306
|
+
!,
|
|
307
|
+
expand_fuzzy(stem(Like, en), Or).
|
|
308
|
+
expand_fuzzy(stem(Like, Lang), Or) :-
|
|
309
|
+
!,
|
|
310
|
+
( atom(Like)
|
|
311
|
+
-> stem_index(Map),
|
|
312
|
+
stem(Like, Lang, Key),
|
|
313
|
+
rdf_find_literal_map(Map, [Key], Tokens),
|
|
314
|
+
list_to_or(Tokens, stem(Like), Or)
|
|
315
|
+
; expand_fuzzy(Like, Or)
|
|
316
|
+
).
|
|
317
|
+
expand_fuzzy(prefix(Prefix), Or) :-
|
|
318
|
+
!,
|
|
319
|
+
( atom(Prefix)
|
|
320
|
+
-> token_index(Map),
|
|
321
|
+
rdf_keys_in_literal_map(Map, prefix(Prefix), Tokens),
|
|
322
|
+
list_to_or(Tokens, prefix(Prefix), Or)
|
|
323
|
+
; expand_fuzzy(Prefix, Or)
|
|
324
|
+
).
|
|
325
|
+
expand_fuzzy(case(String), Or) :-
|
|
326
|
+
!,
|
|
327
|
+
( atom(String)
|
|
328
|
+
-> token_index(Map),
|
|
329
|
+
rdf_keys_in_literal_map(Map, case(String), Tokens),
|
|
330
|
+
list_to_or(Tokens, case(String), Or)
|
|
331
|
+
; expand_fuzzy(String, Or)
|
|
332
|
+
).
|
|
333
|
+
expand_fuzzy(or(A0, B0), E) :-
|
|
334
|
+
!,
|
|
335
|
+
expand_fuzzy(A0, A),
|
|
336
|
+
expand_fuzzy(B0, B),
|
|
337
|
+
simplify(or(A,B), E).
|
|
338
|
+
expand_fuzzy(and(A0, B0), E) :-
|
|
339
|
+
!,
|
|
340
|
+
expand_fuzzy(A0, A),
|
|
341
|
+
expand_fuzzy(B0, B),
|
|
342
|
+
simplify(and(A,B), E).
|
|
343
|
+
expand_fuzzy(not(A0), not(A)) :-
|
|
344
|
+
!,
|
|
345
|
+
expand_fuzzy(A0, A).
|
|
346
|
+
expand_fuzzy(between(Low, High), Or) :-
|
|
347
|
+
!,
|
|
348
|
+
token_index(Map),
|
|
349
|
+
rdf_keys_in_literal_map(Map, between(Low, High), Tokens),
|
|
350
|
+
list_to_or(Tokens, between(Low, High), Or).
|
|
351
|
+
expand_fuzzy(le(High), Or) :-
|
|
352
|
+
!,
|
|
353
|
+
token_index(Map),
|
|
354
|
+
rdf_keys_in_literal_map(Map, le(High), Tokens),
|
|
355
|
+
list_to_or(Tokens, le(High), Or).
|
|
356
|
+
expand_fuzzy(ge(Low), Or) :-
|
|
357
|
+
!,
|
|
358
|
+
token_index(Map),
|
|
359
|
+
rdf_keys_in_literal_map(Map, ge(Low), Tokens),
|
|
360
|
+
list_to_or(Tokens, ge(Low), Or).
|
|
361
|
+
expand_fuzzy(Token, Result) :-
|
|
362
|
+
atomic(Token),
|
|
363
|
+
!,
|
|
364
|
+
( rdf_stopgap_token(Token)
|
|
365
|
+
-> Result = @(stopgap)
|
|
366
|
+
; Result = Token
|
|
367
|
+
).
|
|
368
|
+
expand_fuzzy(Token, _) :-
|
|
369
|
+
throw(error(type_error(Token, boolean_expression), _)).
|
|
370
|
+
|
|
371
|
+
simplify(Expr0, Expr) :-
|
|
372
|
+
simple(Expr0, Expr),
|
|
373
|
+
!.
|
|
374
|
+
simplify(Expr, Expr).
|
|
375
|
+
|
|
376
|
+
simple(and(@(false), _), @(false)).
|
|
377
|
+
simple(and(_, @(false)), @(false)).
|
|
378
|
+
simple(and(@(stopgap), Token), Token).
|
|
379
|
+
simple(and(Token, @(stopgap)), Token).
|
|
380
|
+
simple(or(@(false), X), X).
|
|
381
|
+
simple(or(X, @(false)), X).
|
|
382
|
+
simple(or(@(stopgap), Token), Token).
|
|
383
|
+
simple(or(Token, @(stopgap)), Token).
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
list_to_or([], _, @(false)) :- !.
|
|
387
|
+
list_to_or([X], How, One) :-
|
|
388
|
+
!,
|
|
389
|
+
tag(How, X, One).
|
|
390
|
+
list_to_or([H0|T0], How, or(H, T)) :-
|
|
391
|
+
tag(How, H0, H),
|
|
392
|
+
list_to_or(T0, How, T).
|
|
393
|
+
|
|
394
|
+
tag(sounds(X), Y, sounds(X,Y)).
|
|
395
|
+
tag(stem(X), Y, stem(X,Y)).
|
|
396
|
+
tag(prefix(X), Y, prefix(X,Y)).
|
|
397
|
+
tag(case(X), Y, case(X,Y)).
|
|
398
|
+
tag(between(L,H), Y, between(L,H,Y)).
|
|
399
|
+
tag(ge(L), Y, ge(L,Y)).
|
|
400
|
+
tag(le(H), Y, le(H,Y)).
|
|
401
|
+
|
|
402
|
+
untag(sounds(_,Y), Y).
|
|
403
|
+
untag(stem(_,Y), Y).
|
|
404
|
+
untag(prefix(_,Y), Y).
|
|
405
|
+
untag(case(_,Y), Y).
|
|
406
|
+
untag(between(_,_,Y), Y).
|
|
407
|
+
untag(le(_,Y), Y).
|
|
408
|
+
untag(ge(_,Y), Y).
|
|
409
|
+
|
|
410
|
+
untag(sounds(X,Y), sounds(X), Y).
|
|
411
|
+
untag(stem(X,Y), stem(X), Y).
|
|
412
|
+
untag(prefix(X,Y), prefix(X), Y).
|
|
413
|
+
untag(case(X,Y), case(X), Y).
|
|
414
|
+
untag(between(L,H,Y), between(L,H), Y).
|
|
415
|
+
untag(ge(L,Y), ge(L), Y).
|
|
416
|
+
untag(le(H,Y), le(H), Y).
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
%! nnf(+Formula, -NNF)
|
|
420
|
+
%
|
|
421
|
+
% Rewrite to Negative Normal Form, meaning negations only appear
|
|
422
|
+
% around literals.
|
|
423
|
+
|
|
424
|
+
nnf(not(not(A0)), A) :-
|
|
425
|
+
!,
|
|
426
|
+
nnf(A0, A).
|
|
427
|
+
nnf(not(and(A0,B0)), or(A,B)) :-
|
|
428
|
+
!,
|
|
429
|
+
nnf(not(A0), A),
|
|
430
|
+
nnf(not(B0), B).
|
|
431
|
+
nnf(not(or(A0,B0)), and(A,B)) :-
|
|
432
|
+
!,
|
|
433
|
+
nnf(not(A0), A),
|
|
434
|
+
nnf(not(B0), B).
|
|
435
|
+
nnf(A, A).
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
%! dnf(+NNF, -DNF)
|
|
439
|
+
%
|
|
440
|
+
% Convert a formula in NNF to Disjunctive Normal Form (DNF)
|
|
441
|
+
|
|
442
|
+
dnf(or(A0,B0), or(A, B)) :-
|
|
443
|
+
!,
|
|
444
|
+
dnf(A0, A),
|
|
445
|
+
dnf(B0, B).
|
|
446
|
+
dnf(and(A0,B0), DNF):-
|
|
447
|
+
!,
|
|
448
|
+
dnf(A0, A1),
|
|
449
|
+
dnf(B0, B1),
|
|
450
|
+
dnf1(and(A1,B1), DNF).
|
|
451
|
+
dnf(DNF, DNF).
|
|
452
|
+
|
|
453
|
+
dnf1(and(A0, or(B,C)), or(P,Q)) :-
|
|
454
|
+
!,
|
|
455
|
+
dnf1(and(A0,B), P),
|
|
456
|
+
dnf1(and(A0,C), Q).
|
|
457
|
+
dnf1(and(or(B,C), A0), or(P,Q)) :-
|
|
458
|
+
!,
|
|
459
|
+
dnf1(and(A0,B), P),
|
|
460
|
+
dnf1(and(A0,C), Q).
|
|
461
|
+
dnf1(DNF, DNF).
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
/*******************************
|
|
465
|
+
* TOKEN INDEX *
|
|
466
|
+
*******************************/
|
|
467
|
+
|
|
468
|
+
%! token_index(-Map)
|
|
469
|
+
%
|
|
470
|
+
% Get the index of tokens. If not present, create one from the
|
|
471
|
+
% current database. Once created, the map is kept up-to-date using
|
|
472
|
+
% a monitor hook.
|
|
473
|
+
|
|
474
|
+
token_index(Map) :-
|
|
475
|
+
literal_map(token, Map),
|
|
476
|
+
!,
|
|
477
|
+
wait_for_map(token).
|
|
478
|
+
token_index(Map) :-
|
|
479
|
+
rdf_new_literal_map(Map),
|
|
480
|
+
assert(literal_map(token, Map)),
|
|
481
|
+
register_token_updater,
|
|
482
|
+
message_queue_create(Queue),
|
|
483
|
+
assert(map_building(token, Queue)),
|
|
484
|
+
thread_create(make_literal_index(Queue), _,
|
|
485
|
+
[ alias('__rdf_tokenizer'),
|
|
486
|
+
detached(true)
|
|
487
|
+
]),
|
|
488
|
+
wait_for_map(token).
|
|
489
|
+
|
|
490
|
+
register_token_updater :-
|
|
491
|
+
Monitor = [ reset,
|
|
492
|
+
new_literal,
|
|
493
|
+
old_literal
|
|
494
|
+
],
|
|
495
|
+
( setting(index(default))
|
|
496
|
+
-> create_update_literal_thread(1),
|
|
497
|
+
rdf_monitor(thread_monitor_literal, Monitor)
|
|
498
|
+
; setting(index(thread(N)))
|
|
499
|
+
-> create_update_literal_thread(N),
|
|
500
|
+
rdf_monitor(thread_monitor_literal, Monitor)
|
|
501
|
+
; rdf_monitor(monitor_literal, Monitor)
|
|
502
|
+
).
|
|
503
|
+
|
|
504
|
+
make_literal_index(Queue) :-
|
|
505
|
+
call_cleanup(
|
|
506
|
+
make_literal_index,
|
|
507
|
+
( message_queue_destroy(Queue),
|
|
508
|
+
retractall(map_building(token, _)))).
|
|
509
|
+
|
|
510
|
+
%! make_literal_index
|
|
511
|
+
%
|
|
512
|
+
% Create the initial literal index.
|
|
513
|
+
|
|
514
|
+
make_literal_index :-
|
|
515
|
+
setting(index_threads(N)),
|
|
516
|
+
!,
|
|
517
|
+
threaded_literal_index(N),
|
|
518
|
+
verbose('~N', []).
|
|
519
|
+
make_literal_index :-
|
|
520
|
+
current_prolog_flag(cpu_count, X),
|
|
521
|
+
threaded_literal_index(X),
|
|
522
|
+
verbose('~N', []).
|
|
523
|
+
|
|
524
|
+
threaded_literal_index(N) :-
|
|
525
|
+
N > 1,
|
|
526
|
+
!,
|
|
527
|
+
message_queue_create(Q, [max_size(1000)]),
|
|
528
|
+
create_index_threads(N, Q, Ids),
|
|
529
|
+
forall(rdf_current_literal(Literal),
|
|
530
|
+
thread_send_message(Q, Literal)),
|
|
531
|
+
forall(between(1, N, _),
|
|
532
|
+
thread_send_message(Q, done(true))),
|
|
533
|
+
maplist(thread_join, Ids, _).
|
|
534
|
+
threaded_literal_index(_) :-
|
|
535
|
+
forall(rdf_current_literal(Literal),
|
|
536
|
+
register_literal(Literal)).
|
|
537
|
+
|
|
538
|
+
create_index_threads(N, Q, [Id|T]) :-
|
|
539
|
+
N > 0,
|
|
540
|
+
!,
|
|
541
|
+
thread_create(index_worker(Q), Id, []),
|
|
542
|
+
N2 is N - 1,
|
|
543
|
+
create_index_threads(N2, Q, T).
|
|
544
|
+
create_index_threads(_, _, []) :- !.
|
|
545
|
+
|
|
546
|
+
index_worker(Queue) :-
|
|
547
|
+
repeat,
|
|
548
|
+
thread_get_message(Queue, Msg),
|
|
549
|
+
work(Msg).
|
|
550
|
+
|
|
551
|
+
work(done(true)) :- !.
|
|
552
|
+
work(Literal) :-
|
|
553
|
+
register_literal(Literal),
|
|
554
|
+
fail.
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
%! clean_token_index
|
|
558
|
+
%
|
|
559
|
+
% Clean after a reset.
|
|
560
|
+
|
|
561
|
+
clean_token_index :-
|
|
562
|
+
forall(literal_map(_, Map),
|
|
563
|
+
rdf_reset_literal_map(Map)),
|
|
564
|
+
retractall(stopgap(_)).
|
|
565
|
+
|
|
566
|
+
%! rdf_delete_literal_index(+Type)
|
|
567
|
+
%
|
|
568
|
+
% Fully delete a literal index
|
|
569
|
+
|
|
570
|
+
rdf_delete_literal_index(Type) :-
|
|
571
|
+
must_be(atom, Type),
|
|
572
|
+
( retract(literal_map(Type, Map))
|
|
573
|
+
-> rdf_reset_literal_map(Map) % destroy is unsafe
|
|
574
|
+
).
|
|
575
|
+
|
|
576
|
+
/*******************************
|
|
577
|
+
* THREADED UPDATE *
|
|
578
|
+
*******************************/
|
|
579
|
+
|
|
580
|
+
%! create_update_literal_thread(+Threads)
|
|
581
|
+
%
|
|
582
|
+
% Setup literal monitoring using threads. While loading databases
|
|
583
|
+
% through rdf_attach_db/2 from rdf_persistency.pl, most of the
|
|
584
|
+
% time is spent updating the literal token database. While loading
|
|
585
|
+
% the RDF triples, most of the time is spend in updating the AVL
|
|
586
|
+
% tree holding the literals. Updating the token index hangs on
|
|
587
|
+
% updating the AVL trees holding the tokens. Both tasks however
|
|
588
|
+
% can run concurrently.
|
|
589
|
+
|
|
590
|
+
create_update_literal_thread(Threads) :-
|
|
591
|
+
message_queue_create(_,
|
|
592
|
+
[ alias(rdf_literal_monitor_queue),
|
|
593
|
+
max_size(50000)
|
|
594
|
+
]),
|
|
595
|
+
forall(between(1, Threads, _),
|
|
596
|
+
create_index_worker(initial)).
|
|
597
|
+
|
|
598
|
+
:- dynamic
|
|
599
|
+
index_worker_id/1,
|
|
600
|
+
extra_worker_count/1.
|
|
601
|
+
|
|
602
|
+
create_index_worker(Status) :-
|
|
603
|
+
( retract(index_worker_id(Id0))
|
|
604
|
+
-> true
|
|
605
|
+
; Id0 = 1
|
|
606
|
+
),
|
|
607
|
+
succ(Id0, Id1),
|
|
608
|
+
assertz(index_worker_id(Id1)),
|
|
609
|
+
atom_concat(rdf_literal_monitor_, Id0, Alias),
|
|
610
|
+
inc_extra_worker_count(Status),
|
|
611
|
+
thread_create(monitor_literals(Status), _,
|
|
612
|
+
[ alias(Alias)
|
|
613
|
+
]).
|
|
614
|
+
|
|
615
|
+
monitor_literals(initial) :-
|
|
616
|
+
set_prolog_flag(agc_margin, 0), % we don't create garbage
|
|
617
|
+
repeat,
|
|
618
|
+
thread_get_message(rdf_literal_monitor_queue, Literal),
|
|
619
|
+
register_literal(Literal),
|
|
620
|
+
fail.
|
|
621
|
+
monitor_literals(extra) :-
|
|
622
|
+
set_prolog_flag(agc_margin, 0),
|
|
623
|
+
repeat,
|
|
624
|
+
( thread_get_message(rdf_literal_monitor_queue, Literal,
|
|
625
|
+
[ timeout(1)
|
|
626
|
+
])
|
|
627
|
+
-> register_literal(Literal),
|
|
628
|
+
fail
|
|
629
|
+
; !
|
|
630
|
+
),
|
|
631
|
+
with_mutex(create_index_worker, dec_extra_worker_count),
|
|
632
|
+
thread_self(Me),
|
|
633
|
+
thread_detach(Me).
|
|
634
|
+
|
|
635
|
+
thread_monitor_literal(new_literal(Literal)) :-
|
|
636
|
+
!,
|
|
637
|
+
thread_send_message(rdf_literal_monitor_queue, Literal).
|
|
638
|
+
thread_monitor_literal(Action) :-
|
|
639
|
+
!,
|
|
640
|
+
monitor_literal(Action).
|
|
641
|
+
|
|
642
|
+
%! check_index_workers(+Queue, +Keys)
|
|
643
|
+
%
|
|
644
|
+
% Increase the number of workers indexing literals sent to Queue
|
|
645
|
+
% if the queue gets overfull.
|
|
646
|
+
|
|
647
|
+
check_index_workers(Alias, Keys) :-
|
|
648
|
+
max_extra_workers(Max),
|
|
649
|
+
Max > 0,
|
|
650
|
+
message_queue_property(Queue, alias(Alias)),
|
|
651
|
+
message_queue_property(Queue, size(Size)),
|
|
652
|
+
Size > 10000,
|
|
653
|
+
\+ ( extra_worker_count(Extra),
|
|
654
|
+
Extra >= Max
|
|
655
|
+
),
|
|
656
|
+
!,
|
|
657
|
+
debug(rdf_litindex,
|
|
658
|
+
'Creating extra literal indexer (Queue=~D, Keys=~D)',
|
|
659
|
+
[Size, Keys]),
|
|
660
|
+
with_mutex(create_index_worker, create_index_worker(extra)).
|
|
661
|
+
check_index_workers(_, _).
|
|
662
|
+
|
|
663
|
+
inc_extra_worker_count(extra) :-
|
|
664
|
+
!,
|
|
665
|
+
( retract(extra_worker_count(C0))
|
|
666
|
+
-> C is C0+1
|
|
667
|
+
; C = 1
|
|
668
|
+
),
|
|
669
|
+
asserta(extra_worker_count(C)).
|
|
670
|
+
inc_extra_worker_count(_).
|
|
671
|
+
|
|
672
|
+
dec_extra_worker_count :-
|
|
673
|
+
retract(extra_worker_count(C0)),
|
|
674
|
+
!,
|
|
675
|
+
C is C0-1,
|
|
676
|
+
asserta(extra_worker_count(C)).
|
|
677
|
+
dec_extra_worker_count.
|
|
678
|
+
|
|
679
|
+
max_extra_workers(Max) :-
|
|
680
|
+
current_prolog_flag(cpu_count, Count),
|
|
681
|
+
Max is Count//2.
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
/*******************************
|
|
685
|
+
* MONITORED UPDATE *
|
|
686
|
+
*******************************/
|
|
687
|
+
|
|
688
|
+
monitor_literal(new_literal(Literal)) :-
|
|
689
|
+
register_literal(Literal).
|
|
690
|
+
monitor_literal(old_literal(Literal)) :-
|
|
691
|
+
unregister_literal(Literal).
|
|
692
|
+
monitor_literal(transaction(begin, reset)) :-
|
|
693
|
+
rdf_monitor(monitor_literal, [-old_literal]),
|
|
694
|
+
clean_token_index.
|
|
695
|
+
monitor_literal(transaction(end, reset)) :-
|
|
696
|
+
rdf_monitor(monitor_literal, [+old_literal]).
|
|
697
|
+
|
|
698
|
+
%! register_literal(+Literal)
|
|
699
|
+
%
|
|
700
|
+
% Associate the tokens of a literal with the literal itself.
|
|
701
|
+
|
|
702
|
+
register_literal(Literal) :-
|
|
703
|
+
( rdf_tokenize_literal(Literal, Tokens0)
|
|
704
|
+
-> sort(Tokens0, Tokens),
|
|
705
|
+
text_of(Literal, Lang, Text),
|
|
706
|
+
literal_map(token, Map),
|
|
707
|
+
add_tokens(Tokens, Lang, Text, Map)
|
|
708
|
+
; true
|
|
709
|
+
).
|
|
710
|
+
|
|
711
|
+
add_tokens([], _, _, _).
|
|
712
|
+
add_tokens([H|T], Lang, Literal, Map) :-
|
|
713
|
+
rdf_insert_literal_map(Map, H, Literal, Keys),
|
|
714
|
+
( var(Keys)
|
|
715
|
+
-> ( rdf_keys_in_literal_map(Map, key(H), Count),
|
|
716
|
+
setting(stopgap_threshold(Threshold)),
|
|
717
|
+
Count > Threshold
|
|
718
|
+
-> assert(stopgap(H)),
|
|
719
|
+
rdf_delete_literal_map(Map, H)
|
|
720
|
+
; true
|
|
721
|
+
)
|
|
722
|
+
; forall(new_token(H, Lang), true),
|
|
723
|
+
( Keys mod 1000 =:= 0
|
|
724
|
+
-> progress(Map, 'Tokens'),
|
|
725
|
+
( Keys mod 10000 =:= 0
|
|
726
|
+
-> check_index_workers(rdf_literal_monitor_queue, Keys)
|
|
727
|
+
; true
|
|
728
|
+
)
|
|
729
|
+
; true
|
|
730
|
+
)
|
|
731
|
+
),
|
|
732
|
+
add_tokens(T, Lang, Literal, Map).
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
%! unregister_literal(+Literal)
|
|
736
|
+
%
|
|
737
|
+
% Literal is removed from the database. As we abstract from lang
|
|
738
|
+
% and type qualifiers we first have to check this is the last one
|
|
739
|
+
% that is destroyed.
|
|
740
|
+
|
|
741
|
+
unregister_literal(Literal) :-
|
|
742
|
+
text_of(Literal, _Lang, Text),
|
|
743
|
+
( rdf(_,_,literal(Text))
|
|
744
|
+
-> true % still something left
|
|
745
|
+
; rdf_tokenize_literal(Literal, Tokens0),
|
|
746
|
+
sort(Tokens0, Tokens),
|
|
747
|
+
literal_map(token, Map),
|
|
748
|
+
del_tokens(Tokens, Text, Map)
|
|
749
|
+
).
|
|
750
|
+
|
|
751
|
+
del_tokens([], _, _).
|
|
752
|
+
del_tokens([H|T], Literal, Map) :-
|
|
753
|
+
rdf_delete_literal_map(Map, H, Literal),
|
|
754
|
+
del_tokens(T, Literal, Map).
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
%! rdf_tokenize_literal(+Literal, -Tokens) is semidet.
|
|
758
|
+
%
|
|
759
|
+
% Tokenize a literal. We make this hookable as tokenization is
|
|
760
|
+
% generally domain dependent.
|
|
761
|
+
|
|
762
|
+
rdf_tokenize_literal(Literal, Tokens) :-
|
|
763
|
+
tokenization(Literal, Tokens),
|
|
764
|
+
!. % Hook
|
|
765
|
+
rdf_tokenize_literal(Literal, Tokens) :-
|
|
766
|
+
text_of(Literal, _Lang, Text),
|
|
767
|
+
atom(Text),
|
|
768
|
+
tokenize_atom(Text, Tokens0),
|
|
769
|
+
select_tokens(Tokens0, Tokens).
|
|
770
|
+
|
|
771
|
+
select_tokens([], []).
|
|
772
|
+
select_tokens([H|T0], T) :-
|
|
773
|
+
( exclude_from_index(token, H)
|
|
774
|
+
-> select_tokens(T0, T)
|
|
775
|
+
; number(H)
|
|
776
|
+
-> ( integer(H),
|
|
777
|
+
between(-1073741824, 1073741823, H)
|
|
778
|
+
-> T = [H|T1],
|
|
779
|
+
select_tokens(T0, T1)
|
|
780
|
+
; select_tokens(T0, T)
|
|
781
|
+
)
|
|
782
|
+
; atom_length(H, 1)
|
|
783
|
+
-> select_tokens(T0, T)
|
|
784
|
+
; default_stopgap(H)
|
|
785
|
+
-> select_tokens(T0, T)
|
|
786
|
+
; stopgap(H)
|
|
787
|
+
-> select_tokens(T0, T)
|
|
788
|
+
; T = [H|T1],
|
|
789
|
+
select_tokens(T0, T1)
|
|
790
|
+
).
|
|
791
|
+
|
|
792
|
+
%! rdf_stopgap_token(-Token) is nondet.
|
|
793
|
+
%
|
|
794
|
+
% True when Token is a stopgap token. Currently, this implies one
|
|
795
|
+
% of:
|
|
796
|
+
%
|
|
797
|
+
% - exclude_from_index(token, Token) is true
|
|
798
|
+
% - default_stopgap(Token) is true
|
|
799
|
+
% - Token is an atom of length 1
|
|
800
|
+
% - Token was added to the dynamic stopgap token set because
|
|
801
|
+
% it appeared in more than _stopgap_threshold_ literals.
|
|
802
|
+
|
|
803
|
+
rdf_stopgap_token(Token) :-
|
|
804
|
+
( var(Token)
|
|
805
|
+
-> rdf_stopgap_token2(Token)
|
|
806
|
+
; rdf_stopgap_token2(Token), !
|
|
807
|
+
).
|
|
808
|
+
|
|
809
|
+
rdf_stopgap_token2(Token) :-
|
|
810
|
+
exclude_from_index(token, Token).
|
|
811
|
+
rdf_stopgap_token2(Token) :-
|
|
812
|
+
default_stopgap(Token).
|
|
813
|
+
rdf_stopgap_token2(Token) :-
|
|
814
|
+
atom(Token),
|
|
815
|
+
atom_length(Token, 1).
|
|
816
|
+
rdf_stopgap_token2(Token) :-
|
|
817
|
+
stopgap(Token).
|
|
818
|
+
|
|
819
|
+
%! default_stopgap(?Token)
|
|
820
|
+
%
|
|
821
|
+
% Tokens we do not wish to index, as they create huge amounts of
|
|
822
|
+
% data with little or no value. Is there a more general way to
|
|
823
|
+
% describe this? Experience shows that simply word count is not a
|
|
824
|
+
% good criterion as it often rules out popular domain terms.
|
|
825
|
+
|
|
826
|
+
default_stopgap(and).
|
|
827
|
+
default_stopgap(an).
|
|
828
|
+
default_stopgap(or).
|
|
829
|
+
default_stopgap(of).
|
|
830
|
+
default_stopgap(on).
|
|
831
|
+
default_stopgap(in).
|
|
832
|
+
default_stopgap(this).
|
|
833
|
+
default_stopgap(the).
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
%! text_of(+LiteralArg, -Lang, -Text) is semidet.
|
|
837
|
+
%
|
|
838
|
+
% Get the textual or (integer) numerical information from a
|
|
839
|
+
% literal value. Lang is the language to use for stemming.
|
|
840
|
+
% Currently we use English for untyped plain literals or literals
|
|
841
|
+
% typed xsd:string. Formally, these should not be tokenized, but a
|
|
842
|
+
% lot of data out there does not tag strings with their language.
|
|
843
|
+
|
|
844
|
+
text_of(type(xsd:string, Text), en, Text) :- !.
|
|
845
|
+
text_of(type(_, Text), -, Text) :- !.
|
|
846
|
+
text_of(lang(Lang, Text), Lang, Text) :- !.
|
|
847
|
+
text_of(Text, en, Text) :- atom(Text), !.
|
|
848
|
+
text_of(Text, -, Text) :- integer(Text).
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
/*******************************
|
|
852
|
+
* STEM INDEX *
|
|
853
|
+
*******************************/
|
|
854
|
+
|
|
855
|
+
%! stem_index(-Map) is det.
|
|
856
|
+
%
|
|
857
|
+
% Get the stemming literal index. This index is created on demand.
|
|
858
|
+
% If some thread is creating the index, other threads wait for its
|
|
859
|
+
% completion.
|
|
860
|
+
|
|
861
|
+
stem_index(Map) :-
|
|
862
|
+
literal_map(stem, Map),
|
|
863
|
+
!,
|
|
864
|
+
wait_for_map(stem).
|
|
865
|
+
stem_index(Map) :-
|
|
866
|
+
rdf_new_literal_map(Map),
|
|
867
|
+
assert(literal_map(stem, Map)),
|
|
868
|
+
assert((new_token(Token, Lang) :- add_stem(Token, Lang, Map))),
|
|
869
|
+
message_queue_create(Queue),
|
|
870
|
+
assert(map_building(stem, Queue)),
|
|
871
|
+
thread_create(fill_stem_index(Map, Queue), _,
|
|
872
|
+
[ alias('__rdf_stemmer'),
|
|
873
|
+
detached(true)
|
|
874
|
+
]),
|
|
875
|
+
wait_for_map(stem).
|
|
876
|
+
|
|
877
|
+
wait_for_map(MapName) :-
|
|
878
|
+
( map_building(MapName, Queue)
|
|
879
|
+
-> catch(thread_get_message(Queue, _), _, true),
|
|
880
|
+
wait_for_map(MapName)
|
|
881
|
+
; true
|
|
882
|
+
).
|
|
883
|
+
|
|
884
|
+
fill_stem_index(StemMap, Queue) :-
|
|
885
|
+
call_cleanup(
|
|
886
|
+
forall(rdf_current_literal(Literal),
|
|
887
|
+
stem_literal_tokens(Literal, StemMap)),
|
|
888
|
+
( message_queue_destroy(Queue),
|
|
889
|
+
retractall(map_building(stem, _)))).
|
|
890
|
+
|
|
891
|
+
stem_literal_tokens(Literal, StemMap) :-
|
|
892
|
+
rdf_tokenize_literal(Literal, Tokens),
|
|
893
|
+
!,
|
|
894
|
+
sort(Tokens, Tokens1),
|
|
895
|
+
text_of(Literal, Lang, _Text),
|
|
896
|
+
insert_tokens_stem(Tokens1, Lang, StemMap).
|
|
897
|
+
stem_literal_tokens(_,_).
|
|
898
|
+
|
|
899
|
+
insert_tokens_stem([], _, _).
|
|
900
|
+
insert_tokens_stem([Token|T], Lang, Map) :-
|
|
901
|
+
( atom(Token)
|
|
902
|
+
-> ( stem(Token, Lang, Stem)
|
|
903
|
+
-> rdf_insert_literal_map(Map, Stem, Token, Keys),
|
|
904
|
+
( integer(Keys),
|
|
905
|
+
Keys mod 1000 =:= 0
|
|
906
|
+
-> progress(Map, 'Stem')
|
|
907
|
+
; true
|
|
908
|
+
)
|
|
909
|
+
; true
|
|
910
|
+
)
|
|
911
|
+
; true
|
|
912
|
+
),
|
|
913
|
+
insert_tokens_stem(T, Lang, Map).
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
add_stem(Token, Lang, Map) :-
|
|
917
|
+
stem(Lang, Token, Stem),
|
|
918
|
+
rdf_insert_literal_map(Map, Stem, Token, _).
|
|
919
|
+
|
|
920
|
+
stem(Token, LangSpec, Stem) :-
|
|
921
|
+
main_lang(LangSpec, Lang),
|
|
922
|
+
downcase_atom(Token, Lower),
|
|
923
|
+
catch(snowball(Lang, Lower, Stem), _, fail).
|
|
924
|
+
|
|
925
|
+
main_lang(LangSpec, Lang) :-
|
|
926
|
+
sub_atom(LangSpec, Before, _, _, -),
|
|
927
|
+
!,
|
|
928
|
+
sub_atom(LangSpec, 0, Before, _, Lang).
|
|
929
|
+
main_lang(LangSpec, Lang) :-
|
|
930
|
+
downcase_atom(LangSpec, Lang).
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
/*******************************
|
|
934
|
+
* METAPHONE INDEX *
|
|
935
|
+
*******************************/
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
metaphone_index(Map) :-
|
|
939
|
+
literal_map(metaphone, Map),
|
|
940
|
+
!,
|
|
941
|
+
wait_for_map(metaphone).
|
|
942
|
+
metaphone_index(Map) :-
|
|
943
|
+
rdf_new_literal_map(Map),
|
|
944
|
+
assert(literal_map(metaphone, Map)),
|
|
945
|
+
assert((new_token(Token, Lang) :- add_metaphone(Token, Lang, Map))),
|
|
946
|
+
message_queue_create(Queue),
|
|
947
|
+
assert(map_building(metaphone, Queue)),
|
|
948
|
+
thread_create(fill_metaphone_index(Map, Queue), _,
|
|
949
|
+
[ alias('__rdf_metaphone_indexer'),
|
|
950
|
+
detached(true)
|
|
951
|
+
]),
|
|
952
|
+
wait_for_map(metaphone).
|
|
953
|
+
|
|
954
|
+
fill_metaphone_index(MetaphoneMap, Queue) :-
|
|
955
|
+
call_cleanup(
|
|
956
|
+
fill_metaphone_index(MetaphoneMap),
|
|
957
|
+
( message_queue_destroy(Queue),
|
|
958
|
+
retractall(map_building(metaphone, _)))).
|
|
959
|
+
|
|
960
|
+
fill_metaphone_index(MetaphoneMap) :-
|
|
961
|
+
token_index(TokenMap),
|
|
962
|
+
rdf_keys_in_literal_map(TokenMap, all, Tokens),
|
|
963
|
+
metaphone(Tokens, MetaphoneMap).
|
|
964
|
+
|
|
965
|
+
metaphone([], _).
|
|
966
|
+
metaphone([Token|T], Map) :-
|
|
967
|
+
( atom(Token),
|
|
968
|
+
double_metaphone(Token, SoundEx)
|
|
969
|
+
-> rdf_insert_literal_map(Map, SoundEx, Token, Keys),
|
|
970
|
+
( integer(Keys),
|
|
971
|
+
Keys mod 1000 =:= 0
|
|
972
|
+
-> progress(Map, 'Metaphone')
|
|
973
|
+
; true
|
|
974
|
+
)
|
|
975
|
+
; true
|
|
976
|
+
),
|
|
977
|
+
metaphone(T, Map).
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
add_metaphone(Token, _Lang, Map) :-
|
|
981
|
+
atom(Token),
|
|
982
|
+
!,
|
|
983
|
+
double_metaphone(Token, SoundEx),
|
|
984
|
+
rdf_insert_literal_map(Map, SoundEx, Token).
|
|
985
|
+
add_metaphone(_, _, _).
|
|
986
|
+
|
|
987
|
+
%! rdf_literal_index(+Type, -Index) is det.
|
|
988
|
+
%
|
|
989
|
+
% True when Index is a literal map containing the index of Type.
|
|
990
|
+
% Type is one of:
|
|
991
|
+
%
|
|
992
|
+
% - token
|
|
993
|
+
% Tokens are basically words of literal values. See
|
|
994
|
+
% rdf_tokenize_literal/2. The `token` map maps tokens to full
|
|
995
|
+
% literal texts.
|
|
996
|
+
% - stem
|
|
997
|
+
% Index of stemmed tokens. If the language is available, the
|
|
998
|
+
% tokens are stemmed using the matching _snowball_ stemmer.
|
|
999
|
+
% The `stem` map maps stemmed to full tokens.
|
|
1000
|
+
% - metaphone
|
|
1001
|
+
% Phonetic index of tokens. The `metaphone` map maps phonetic
|
|
1002
|
+
% keys to tokens.
|
|
1003
|
+
|
|
1004
|
+
rdf_literal_index(token, Map) :-
|
|
1005
|
+
!,
|
|
1006
|
+
token_index(Map).
|
|
1007
|
+
rdf_literal_index(stem, Map) :-
|
|
1008
|
+
!,
|
|
1009
|
+
stem_index(Map).
|
|
1010
|
+
rdf_literal_index(metaphone, Map) :-
|
|
1011
|
+
!,
|
|
1012
|
+
metaphone_index(Map).
|
|
1013
|
+
rdf_literal_index(Type, _Map) :-
|
|
1014
|
+
domain_error(literal_index, Type).
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
/*******************************
|
|
1018
|
+
* UTIL *
|
|
1019
|
+
*******************************/
|
|
1020
|
+
|
|
1021
|
+
verbose(Fmt, Args) :-
|
|
1022
|
+
setting(verbose(true)),
|
|
1023
|
+
!,
|
|
1024
|
+
format(user_error, Fmt, Args).
|
|
1025
|
+
verbose(_, _).
|
|
1026
|
+
|
|
1027
|
+
progress(Map, Which) :-
|
|
1028
|
+
setting(verbose(true)),
|
|
1029
|
+
!,
|
|
1030
|
+
rdf_statistics_literal_map(Map, size(Keys, Values)),
|
|
1031
|
+
format(user_error,
|
|
1032
|
+
'\r~t~w: ~12|Keys: ~t~D~15+; Values: ~t~D~20+',
|
|
1033
|
+
[Which, Keys, Values]).
|
|
1034
|
+
progress(_,_).
|
|
1035
|
+
|