Linguistic processing for Db2 Text Search
Db2 Text Search provides dictionary packs to support the linguistic processing of documents and queries. In addition, n-gram segmentation is supported for languages such as Chinese, Japanese, and Korean. As an alternative to dictionary-based word segmentation, the search engine provides an option to select n-gram segmentation for languages such as Chinese, Japanese, and Korean.
If a text document is in one of the supported languages, linguistic processing is carried out during the tokenization stage, that is when then text is broken up into individual words. For unsupported languages, the document is parsed using white space or n-gram segmentation. Lemmatization (like stemming, this means to find the normalized form of a word, but it also analyzes the word's part of speech) is not performed on unsupported languages.
When you search a text search index, a match is indicated if the indexed document contains the query terms or linguistic variations of the query terms. The variations of a word depend on the language of the query.
Linguistic processing for Chinese, Japanese, and Korean documents
For a search engine, getting good search results depends in large part on the techniques that are used to process text. After the text is extracted from the document, the first step in text processing is to identify the individual words in the text. Identifying the individual words in the text is referred to as segmentation. For many languages, white space (blanks, the end of a line, and certain punctuation) can be used to recognize word boundaries. However, Chinese, Japanese, and Korean do not use white space between characters to separate words, so other techniques must be used.
Db2 Text Search provides two processing options for Chinese, Japanese, and Korean: a morphological segmentation option, also called dictionary-based word segmentation, and an n-gram segmentation option (the default setting).
Morphological segmentation uses a language-specific dictionary to identify words in the sequence of characters in the document. This technique provides precise search results, because the dictionaries are used to identify word boundaries.
N-gram segmentation avoids the problem of identifying word boundaries, and instead indexes overlapping pairs of characters. Because two characters are used, this technique is also called bi-gram segmentation. N-gram segmentation always returns all matching documents that contain the search terms. However, this technique can return documents that do not match the query.
Example
To show how both types of linguistic
processing work, examine the following text in a document: election for governor of Kanagawa prefecture. In Japanese,
this text contains eight characters. For this example, the eight characters
are represented as A B C D E F G H. A sample query
that users might enter could be election for governor, which is four
characters and are represented as E F G H. (The document
text and the sample query share similar characters.)
After the document is indexed using morphological segmentation, the search engine segments the text election for governor of
Kanagawaprefecture into the following sets of characters:ABC DEF GH.The sample query election for governor is segmented into the following sets of characters
EF GH. The charactersEFdo not appear in the tokens of the document text. Even though the document does not haveEF, it does haveDEF.Since the document text contains
DEF, but the query contains onlyEF, the document is less likely to be found by using the sample query.When you enable morphological segmentation, you will likely see more precise results, but possibly fewer results.
After the document is indexed using n-gram segmentation , the search engine segments the text election for governor of
Kanagawaprefecture into the following sets of characters:AB BC CD DE EF FG GH.The sample query election for governor is segmented into the following sets of characters:
DE EF FG GH. If you search with the sample queryelection for governor, the document will be found by the query because the tokens for both the document text and the query appear in the same order.When you enable n-gram segmentation, you will likely see more results but possibly less precise results. For example, in Japanese, if you search with the query
Kyotoand a document in your index contains the textCity of Tokyo, the queryKyotowill return the document with the textCity of Tokyo. The reason is thatCity of TokyoandKyotoshare two of the same Japanese characters.