Porter2 aka SnowBall Word Stemming algorithm for .NET2.0
This is a VB.NET implementation of Martin Porter's "Porter2"
aka "SnowBall" algorithm as described at:
This algorithm does not always produce a correctly spelled word. ie "Services" becomes "Servic" (typically "e" suffixes are an issue) as English does not strictly follow rules. This is very good, but the best we can hope for without using a dictionary lookup. It is good enough for searching or matching purposes - which is probably what you want to do. Alternatively you could use dictionaries to stem words - which is generally too big and an overkill for most usages.
It is provided as a ready-to-use class with only a
single public method:
public function stem(word as string) as string
Dim porterStemmer As New Stemmer()
Dim output As String = porterStemmer.stem("wordly")
VB.NET port from C# by Hunter Beanland -
Sections have been ported via compilation and disassembly of MSIL to VB, therefore may appear to be compiler optimised in code (strange coding)
C# implementation written by Kamil Bartocha, email: crow2 (at)
C# version: 1.0.0 - date: 11.04.2007
Copyright 2007 Kamil Bartocha. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY KAMIL BARTOCHA ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
If you improve this code, please send me a copy! Thanks!
hunter @ beanland.net.au