Often, you would like to be able to give users results that matched things that are close to what they searched for, but not exactly. Examples of this kind of behavior include disregarding punctuation, searching for Unicode characters via Roman transliterations or vice versa, ignoring the case of letters in a search string, similarity searching, etc. There and many levels of search term evaluation in Philologic and these different but related problems can be solved in various ways.
Think about it both ways:
In order to get things to work the way you want, you have to understand how Philologic works and figure out what parts to tweak.
When you load a database into Philologic, an index of all the words in the text is created. What is considered to be a word unit is determined by textload.cfg. Look for:
$CHARSINWORD = "[\&A-Za-z0-9\177-\377][\&A-Za-z0-9\177-\377\\-\_\';]*";
That's where you define your word pattern, which contains all the characters that DO NOT cause the word to break. Anything else will break the word and you'll have two separate words (just like with a space.) More on this at: Textload.cfg.
search3t gets the input from the web browser and uses philosubs.pl and crapser to construct the search string. In philosubs.pl, clean_word_pattern performs some preliminary cleaning, then crapser expands the word pattern with folded accents, transliterations, etc. The pattern is then sent to search3 which returns the results.
As described in the crapser entry, crapser replaces some capital letters with a pattern that matches likely accents. If you want to add to this list, just put in some letters or codes separated by pipes (|):
%ACCENTS = ( 'A', "(a|\xc3\xa0|\xc3\xa1|\xc3\xa2|\xc3\xa3|\xc3\xa4)",
Unicode and Roman equivalencies are handled via crapser which uses a two-field file called words.R.wom to make the matches. Here's how it works. When you load your database, Philologic generates a list of all words in the database and writes it out as words.R. It also makes words.R.wom which is (at this point) just a two-fielded list with the exact same words in each field. However, if you replace the second field with something else, it establishes a relationship between the two strings that says: when you get a user searching for stringA, replace that with stringB and search for that instead.
Here's an example. In our words.R.wom, we have this line:
Anyone searching for melee will find meleé in the text.
You can generate your words.R.wom file any way you want, as long as you come out with a file that contains two fields with words separated by tabs. See the make_wom_words.R.pl entry for some examples.
characters.pl is a
By default, case is stripped during the creation of the word index -- indexed words are stored in lower case. Then, crapser folds all search terms to lower case when you run a search, so upper will match lower and vice-versa.
For non-Roman cases in Unicode, the situation is different. Philologic will not make any changes to the case during indexing -- it will index quite literally whatever Unicode is there. So what is one to do if you want case-folded searches on Unicode? Well, you could theoretically do the job with words.R.wom, creating a separate entry for each word containing the characters you want case folded -- one upper, one lower. But the combinatorics quickly get out of hand if you want to be able to search for UpperLowerUpperUpper, e.g., and match combination that has been indexed.
Most punctuation problems can be taken care of simply by setting $CHARSINWORD correctly. See Textload.cfg. For an explanation of how to have a character treated as word-breaking punction and still be able to search with it, see CharsInWord. It all boils down to setting:
$word =~ s/\-/\+/g;
in clean_word_pattern in philosubs.pl.
It is important to note that headword searches are handled completely differently, and therefore none of the above techniques will work for equivalency searching in headwords. Headword searches do not use crapser, but instead use subdocgimme, which searches through divindex.raw. By default, there is no way to search on headwords in anything but their underlying form -- i.e. exactly as they appeared in the input text.
You can work around this, however. Using a modified subdocgimme found in the goodies folder of your installation, you can search on a normalized field in your divindex.raw. To generate the new divindex.raw, you can use a script like this:
You are simply adding a last field which is the romanized form of your headword. Pop the modified subdocgimme from goodies into place, and you are ready to go.
If you want to do this across a range of databaes, you can use a script like this: