ADL_query_translator modules/paradigms/Textual_LikeSubstring.py

modules / paradigms / Textual_LikeSubstring.py 


 SYNOPSIS

     Textual_LikeSubstring (table, idColumn, textColumn, cardinality,
         mapping=TextUtils.mappings.uppercaseAlphanumericOthersToWhitespace,
         deleteList=TextUtils.deleteLists.keepAll, function=None)

         table
             A table to query, e.g., "holding".

         idColumn
             The table's object identifier column (i.e., the column
             to be selected), e.g., "holding_id".

         textColumn
             The table column containing the text to search over
             (i.e., the column against which the constraint is to be
             placed), e.g., "subject_text".

         cardinality
             A Cardinality object representing the cardinality of
             'table' with respect to 'textColumn'.

         mapping
             A Python character mapping table (i.e., a string of
             length 256, indexed by ASCII character code) to process
             constraint text with.  Defaults to
             'uppercaseAlphanumericOthersToWhitespace', which maps
             alphanumeric characters to their uppercase equivalents
             and all other characters to whitespace (i.e., to word
             separators).

         deleteList
             A string of zero or more characters to delete from
             constraint text.  The default is the empty string, which
             keeps all characters.

         function
             A function to apply to 'textColumn' (e.g., "UPPER"), or
             None.  Defaults to None.

 DESCRIPTION

     Approximates a textual constraint with substring matching using
     SQL LIKE operators.

     Given a textual constraint (B, O, T) where B is a textual
     bucket, O is one of the standard textual operators, and T is a
     text string, this paradigm parses T into a sequence of one or
     more words (W1, W2, W3, ...) by: 1) deleting from T any
     characters that appear in 'deleteList'; 2) mapping the remaining
     characters using 'mapping'; and 3) treating sequences of
     whitespace characters as word separators.  The paradigm then
     returns one of the following queries.  If O is
     "contains-all-words":

         SELECT idColumn FROM table
             WHERE textColumn LIKE '%W1%' AND
                   textColumn LIKE '%W2%' AND
                   textColumn LIKE '%W3%' ...

     If O is "contains-any-words":

         SELECT idColumn FROM table
             WHERE textColumn LIKE '%W1%' OR
                   textColumn LIKE '%W2%' OR
                   textColumn LIKE '%W3%' ...

     If O is "contains-phrase":

         SELECT idColumn FROM table
             WHERE textColumn LIKE '%W1%W2%W3%...%'

     If a text column function is specified (e.g., "UPPER"), the
     returned query will have the form:

         SELECT idColumn FROM table
             WHERE UPPER(textColumn) LIKE ...

     The semantics of the "contains-all-words" operator will
     generally be correct only if the cardinality is "1" or "1?".  If
     the cardinality is "0+" or "1+", wrap this paradigm in an
     Adaptor_IndivisibleConcatenation paradigm.

     Exceptions thrown:

         no query words specified

 AUTHOR

     Greg Janee
     gjanee@alexandria.ucsb.edu

 HISTORY

     $Log: Textual_LikeSubstring.py,v $
     Revision 1.2  2003/10/21 20:34:37  gjanee
     Minor (but critical) documentation change.

     Revision 1.1  2002/10/30 05:22:25  gjanee
     Initial revision

Imported Modules   

import UniversalTranslator
import edu.ucsb.adl.middleware
import paradigms
import string
import types

Classes   

Textual_LikeSubstring


This document was automatically generated Thu Mar 4 12:45:25 2004 by HappyDoc version WORKING