Links to resources | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Here is a sample of vocabulary, with the stemmed forms that will be generated with the algorithm.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Developing the English stemmer(Revised slightly, December 2001)(Further revised, September 2002) I have made more than one attempt to improve the structure of the Porter algorithm by making it follow the pattern of ending removal of the Romance language stemmers. It is not hard to see why one should want to do this: step 1b of the Porter stemmer removes ed and ing, which are i-suffixes (*) attached to verbs. If these suffixes are removed, there should be no need to remove d-suffixes which are not verbal, although it will try to do so. This seems to be a deficiency in the Porter stemmer, not shared by the Romance stemmers. Again, the divisions between steps 2, 3 and 4 seem rather arbitrary, and are not found in the Romance stemmers. Nevertheless, these attempts at improvement have been abandoned. They seem to lead to a more complicated algorithm with no very obvious improvements. A reason for not taking note of the outcome of step 1b may be that English endings do not determine word categories quite as strongly as endings in the Romance languages. For example, condition and position in French have to be nouns, but in English they can be verbs as well as nouns,
But it is hardly surprising that after twenty years of use of the Porter stemmer, certain improvements did suggest themselves, and a new algorithm for English is therefore offered here. (It could be called the ‘Porter2’ stemmer to distinguish it from the Porter stemmer, from which it derives.) The changes are not so very extensive: (1) terminating y is changed to i rather less often, (2) suffix us does not lose its s, (3) a few additional suffixes are included for removal, including (4) suffix ly. In addition, a small list of exceptional forms is included. In December 2001 there were two further adjustments: (5) Steps 5a and 5b of the old Porter stemmer were combined into a single step. This means that undoubling final ll is not done with removal of final e. (6) In Step 3 ative is removed only when in region R2. (7) In July 2005 a small adjustment was made (including a new step 0) to handle apostrophe. To begin with, here is the basic algorithm without reference to the exceptional forms. An exact comparison with the Porter algorithm needs to be done quite carefully if done at all. Here we indicate by * points of departure, and by + additional features. In the sample vocabulary, Porter and Porter2 stem slightly under 5% of words to different forms. Definition of the English stemmerDefine a vowel as one of
R2 is the region after the first non-vowel following a vowel in R1, or the end of the word if there is no such non-vowel. (See note on R1 and R2.) Define a short syllable in a word as either (a) a vowel followed by a non-vowel other than w, x or Y and preceded by a non-vowel, or * (b) a vowel at the beginning of the word followed by a non-vowel. So rap, trap, entrap end with a short syllable, and ow, on, at are classed as short syllables. But uproot, bestow, disturb do not end with a short syllable. A word is called short if it ends in a short syllable, and if R1 is null. So bed, shed and shred are short words, bead, embed, beds are not short words. An apostrophe (') may be regarded as a letter. (See note on apostrophes in English.) If the word has two letters or less, leave it as it is. Otherwise, do each of the following operations, Remove initial ', if present. + Then, Set initial y, or y after a vowel, to Y, and then establish the regions R1 and R2. (See note on vowel marking.) Step 0: +
Exceptional forms in generalIt is quite easy to expand a Snowball script so that certain exceptional word forms get special treatment. The standard case is that certain words W1, W2 ..., instead of passing through the stemming process, are mapped to the forms X1, X2 ... respectively. If the script does the stemming by means of the calldefine stem as Cwhere C is a command, the exceptional cases can be dealt with by extending this to define stem as ( exception or C )and putting in a routine exception: define exception as ( [substring] atlimit among( 'W1' ( <- 'X1' ) 'W2' ( <- 'X2' ) ... ) )atlimit causes the whole string to be tested for equality with one of the Wi, and if a match is found, the string is replaced with Xi. More precisely we might have a group of words W11, W12 ... that need to be mapped to X1, another group W21, W22 ... that need to be mapped to X2, and so on, and a list of words V1, V2 ... Vk that are to remain invariant. The exception routine may then be written as follows: among( 'W11' 'W12' ... (<- 'X1') 'W21' 'W22' ... (<- 'X2') ... 'Wn1' 'Wn2' ... (<- 'Xn') 'V1' 'V2' ... 'Vk' )And indeed the exception1 routine for the English stemmer has just that shape: define exception1 as ( [substring] atlimit among( /* special changes: */ 'skis' (<-'ski') 'skies' (<-'sky') 'dying' (<-'die') 'lying' (<-'lie') 'tying' (<-'tie') /* special -LY cases */ 'idly' (<-'idl') 'gently' (<-'gentl') 'ugly' (<-'ugli') 'early' (<-'earli') 'only' (<-'onli') 'singly' (<-'singl') // ... extensions possible here ... /* invariant forms: */ 'sky' 'news' 'howe' 'atlas' 'cosmos' 'bias' 'andes' // not plural forms // ... extensions possible here ... ) )(More will be said about the words that appear here shortly.) Here we see words being treated exceptionally before stemming is done, but equally we could treat stems exceptionally after stemming is done, and so, if we wish, map absorpt to absorb, reduct to reduc etc., as in the Lovins stemmer. But more generally, throughout the algorithm, each significant step may have recognised exceptions, and a suitably placed among will take care of them. For example, a point made at least twice in the literature is that words beginning gener are overstemmed by the Porter stemmer:
gopast v gopast non-v setmark p1with among ( 'gener' // ... and other stems may be included here ... ) or (gopast v gopast non-v) setmark p1after which the words beginning gener stem as follows:
define exception2 as ( [substring] atlimit among( 'inning' 'outing' 'canning' 'herring' 'proceed' 'exceed' 'succeed' // ... extensions possible here ... ) )Snowball makes it easy therefore to add in lists of exceptions. But deciding what the lists of exceptions should be is far from easy. Essentially there are two lines of attack, the systematic and the piecemeal. One might systematically treat as exceptions the stem changes of irregular verbs, for example. The piecemeal approach is to add in exceptions as people notice them — like gener above. The problem with the systematic approach is that it should be done by investigating the entire language vocabulary, and that is more than most people are prepared to do. The problem with the piecemeal approach is that it is arbitrary, and usually yields little. The exception lists in the English stemmer are meant to be illustrative (‘this is how it is done if you want to do it’), and were derived piecemeal. a) The new stemmer improves on the Porter stemmer in handling short words ending e and y. There is however a mishandling of the four forms sky, skies, ski, skis, which is easily corrected by treating three of these words as special cases. b) Similarly there is a problem with the ing form of three letter verbs ending ie. There are only three such verbs: die, lie and tie, so a special case is made for dying, lying and tying. c) One has to be a little careful of certain ing forms. inning, outing, canning, which one does not wish to be stemmed to in, out, can. d) The removal of suffix ly, which is not in the Porter stemmer, has a number of exceptions. Certain short-word exceptions are idly, gently, ugly, early, only, singly. Rarer words (bristly, burly, curly, surly ...) are not included. e) The remaining words were included following complaints from users of the Porter algorithm. news is not the plural of new (noticed when IR systems were being set up for Reuters). Howe is a surname, and needs to be separated from how (noticed when doing a search for ‘Sir Geoffrey Howe’ in a demonstration at the House of Commons). succeed etc are not past participles, so the ed should not be removed (pointed out to me in an email from India). herring should not stem to her (another email from Russia). f) Finally, a few non-plural words ending s have been added. Incidentally, this illustrates how much feedback to expect from the real users of a stemming algorithm: seven or eight words in twenty years! The definition of the English stemmer above is therefore supplemented by the following: Exceptional forms in the English stemmer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The full algorithm in Snowball
|