Handbook
Glossary
step2 ( str -- newstr )
Porter stemming algorithm
Prev:
step1c ( str -- newstr )
Next:
step3 ( str -- newstr )
Vocabulary
porter-stemmer
Inputs
str
a
string
Outputs
newstr
a new string
Word description
Maps double suffices to single ones. so -ization maps to -ize etc. note that the string before the suffix must give positive
consonant-seq
.
Definition
USING:
combinators
splitting
;
IN:
porter-stemmer
:
step2
( str -- newstr )
{
{
[
"ational"
?tail
]
[
"ational"
"ate"
r
]
}
{
[
"tional"
?tail
]
[
"tional"
"tion"
r
]
}
{
[
"enci"
?tail
]
[
"enci"
"ence"
r
]
}
{
[
"anci"
?tail
]
[
"anci"
"ance"
r
]
}
{
[
"izer"
?tail
]
[
"izer"
"ize"
r
]
}
{
[
"bli"
?tail
]
[
"bli"
"ble"
r
]
}
{
[
"alli"
?tail
]
[
"alli"
"al"
r
]
}
{
[
"entli"
?tail
]
[
"entli"
"ent"
r
]
}
{
[
"eli"
?tail
]
[
"eli"
"e"
r
]
}
{
[
"ousli"
?tail
]
[
"ousli"
"ous"
r
]
}
{
[
"ization"
?tail
]
[
"ization"
"ize"
r
]
}
{
[
"ation"
?tail
]
[
"ation"
"ate"
r
]
}
{
[
"ator"
?tail
]
[
"ator"
"ate"
r
]
}
{
[
"alism"
?tail
]
[
"alism"
"al"
r
]
}
{
[
"iveness"
?tail
]
[
"iveness"
"ive"
r
]
}
{
[
"fulness"
?tail
]
[
"fulness"
"ful"
r
]
}
{
[
"ousness"
?tail
]
[
"ousness"
"ous"
r
]
}
{
[
"aliti"
?tail
]
[
"aliti"
"al"
r
]
}
{
[
"iviti"
?tail
]
[
"iviti"
"ive"
r
]
}
{
[
"biliti"
?tail
]
[
"biliti"
"ble"
r
]
}
{
[
"logi"
?tail
]
[
"logi"
"log"
r
]
}
[
]
}
cond
;