• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

Managing external tables for SWI-Prolog
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • Managing external tables for SWI-Prolog
        • Introduction
        • Managing external tables
        • Flexible ordering and equivalence based on character table
          • new_order_table/2
          • order_table_mapping/3
          • compare_strings/4
          • prefix_string/3
          • prefix_string/4
          • sub_string/3
        • Example: accessing the Unix passwd file

3 Flexible ordering and equivalence based on character table

This package was developed as part of the GRASP project, where it is used for browsing lexical and ontology information, which is normally stored using‘dictionary’order, rather than the more conventional alphabetical ordering based on character codes. To achieve programmable ordering, the table package defines‘order tables’. An order table is a table with the cardinality of the size of the character set (256 for extended ASCII), and maps each character onto its‘order number’, and some characters onto special codes.

The default (exact) table matches all character codes onto themselves. The default case_insensitive table matches all uppercase characters onto their corresponding lowercase character. The tables iso_latin_1 and iso_latin_1_case_insensitive map the ISO-latin-1 letters with diacritics into their plain counterpart.

To support dictionary ordering, the following special categories are defined:

ignoreCharacters of the ignore set are simple discarded from the input.
breakCharacters from the break set are treated as word-breaks, and each non-empty sequence of them is considered equal. A word break precedes a normal character.
tagCharacters of type tag indicate the start of a‘tag’that should not be considered in ordering, unless both strings are the same upto the tag.

The following predicates are defined to manage and use these tables:

new_order_table(+Name, +Options)
Create a new, or replace the order-table with the given name (an atom). Options is a list of options:

case_insensitiveMap all upper- to lowercase characters.
iso_latin_1Start with an ISO-Latin-1 table
iso_latin_1_case_insensitiveStart with a case-insensitive ISO-Latin-1 table
copy(+Table)Copy all entries from Table.
tag(+ListOfCodes)Add these characters to the set of‘tag’characters.
ignore(+ListOfCodes)Add these characters to the set of‘ignore’characters.
break(+ListOfCodes)Add these characters to the set of‘break’characters.
+Code1 = +Code2 Map Code1 onto Code2.
order_table_mapping(+Table, ?From, ?To)
Read the current mapping. To is a character code or one of the atoms break, ignore or tag.
compare_strings(+Table, +S1, +S2, -Result)
Compare two strings using the named Table. S1 and S2 may be atoms, strings or code-lists. Result is one of the atoms <, = or >.
prefix_string(+Table, +Prefix, +String)
Succeeds if Prefix is a prefix of String using the named Table.
prefix_string(+Table, +Prefix, -Rest, +String)
Succeeds if Prefix is a prefix of String using the named Table, and Rest is unified with the remainder of String that is not matched. Please note that the existence of an order-table implies simple contatenation using atom_concat/3 cannot be used to determine the non-matched part of the string.
sub_string(+Table, +Sub, +String)
Succeeds if Sub is a substring of String using the named Table.

ClioPatria (version V3.1.1-51-ga0b30a5)