Skip to content

Add the initial version of the Polish stemmer #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions algorithms/index.tt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ We also provide Snowball implementations of some algorithms developed by other p
<li><a href="/algorithms/lithuanian/stemmer.html">Lithuanian</a></li>
<li><a href="/algorithms/serbian/stemmer.html">Serbian</a></li>
<li><a href="/algorithms/yiddish/stemmer.html">Yiddish</a></li>
<li><a href="/algorithms/polish/stemmer.html">Polish</a></li>
</ul>

[% footer %]
21 changes: 21 additions & 0 deletions algorithms/polish/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing seems to actually reference this file, and the PR against the snowball repo doesn't mention this licence.

The Snowball compiler and other algorithms are all released under the 3-clause BSD licence, which is also a permissive licence and really pretty similar in practical terms (it does have an additional "no endorsements" clause, but that shouldn't make a difference to any reasonable use).

Are you happy to just license under 3-clause BSD? I'm not keen to have licence proliferation within the Snowball distribution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomek-ai @tomeklysiak Please respond to this part at least - can we drop this file (i.e. algorithms/polish/LICENSE)?

The PR to add the stemmer to the snowball repo didn't include it, so the stemmer code seems to be implicitly being contributed under the licence of the snowball repo, which is 3-clause BSD.

So it seems this is just meant to apply to the algorithm description in this PR. Whatever is meant, I really don't want to have a proliferation of licences in the project (and it would be unhelpful to have to think about licensing if, for example, we later wanted to reuse parts of the algorithm description as code comments).

It would be useful to respond to my other question too, but that one isn't really a blocker to merging.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ojwb @mitya57 The PR was created more than three years ago, but from what I remember, the Polish stemmer logic originates from an MIT-licensed Python project. The implementation in Snowball was created independently, using the same principles but rewritten from scratch and adapted to Snowball’s structure. The MIT license was included as an acknowledgment of the original inspiration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for clarifying.

That's all fine, I'll adjust the documentation to credit the creator and link to the original repo. We should be able to get this merged.


Copyright (c) 2017 Błażej Kubiński

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
166 changes: 166 additions & 0 deletions algorithms/polish/stemmer.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
[% header('Polish stemming algorithm') %]

<h2>Links to resources</h2>

<ul>
[% algorithm_lis('polish', 'Polish') %]
</ul>

[% algorithm_vocab([20, 'babicka', 'maaru']) %]

<h2>The stemming algorithm</h2>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the origin of the algorithm?

If there's a paper or a description of it somewhere, it's helpful to reference it.

If it's just something you devised, that's OK but it's useful to say that (and really you should get credit for creating it).


<p>
The Polish alphabet includes the following additional letters,
</p>

<DL><DD>
<B><I>ą &nbsp; ę &nbsp; ó &nbsp; ł &nbsp; ć &nbsp; ś</I></B>
</DL>

<p>
The following letters are vowels:
</p>

<DL><DD>
<B><I>a &nbsp; ą &nbsp; e &nbsp; ę &nbsp; i &nbsp; o &nbsp; ó &nbsp; u &nbsp; y</I></B>
</DL>


<p>
Do each of steps 1, 2, 3, 4, 5, 6 and 7.
</p>

<p>
<B>Step 1. Remove nouns:</B>
</p>

<DL><DD>
<DL>
<DT>(<I>a</I>)
If a length of the word is over 7 letters and the ending is one of the following:
<B><I>zacja &nbsp; zacją &nbsp; zacji</I></B>
<DD>delete the ending
<DT>(<I>b</I>)
If a length of the word is over 6 letters and the ending is one of the following:
<B><I>acja &nbsp; acji &nbsp; acją &nbsp; tach &nbsp; anie &nbsp; enie &nbsp; eniu &nbsp; aniu</I></B>
<DD>delete the ending
<DT>(<I>c</I>)
If a length of the word is over 6 letters and the ending is:
<B><I>tyka</I></B>
<DD>delete the last 2 letters
<DT>(<I>d/I>)
If a length of the word is over 5 letters and the ending is one of the following:
<B><I>ach &nbsp; ami &nbsp; nia &nbsp; niu &nbsp; cia &nbsp; ciu &nbsp; cji &nbsp; cja &nbsp; cją &nbsp;
ce &nbsp; ta</I></B>
<DD>delete the ending
</DL>
</DL>

<p>
<B>Step 2. Remove dimunitive:</B>
</p>

<DL><DD>
<DL>
<DT>(<I>a</I>)
If a length of the word is over 6 letters and the ending is one of the following:
<B><I>eczek &nbsp; iczek &nbsp; iszek &nbsp; aszek &nbsp; uszek</I></B>
<DD>delete the ending
<DT>(<I>b</I>)
If a length of the word is over 6 letters and the ending is one of the following:
<B><I>enek &nbsp; ejek &nbsp; erek</I></B>
<DD>delete the last 2 letters
<DT>(<I>c</I>)
If a length of the word is over 4 letters and the ending is one of the following:
<B><I>ek &nbsp; ak </I></B>
<DD>delete the ending
</DL>
</DL>

<p>
<B>Step 3. Remove adjectives endings:</B>
</p>

<DL><DD>
<DL>
<DT>(<I>a</I>)
If a length of the word is over 7 letters, word begins with <B><I>naj</I></B> and the ending is one of the following:
<B><I>sze &nbsp; szy &nbsp; szych</I></B>
<DD>delete the beginning <B><I>(naj)</I></B> and the ending
<DT>(<I>b</I>)
If a length of the word is over 6 letters and the ending is:
<B><I>czny</I></B>
<DD>delete the ending
<DT>(<I>c</I>)
If a length of the word is over 5 letters and the ending is one of the following:
<B><I>owy &nbsp; owa &nbsp; owe &nbsp; ych &nbsp; ego &nbsp; ej</I></B>
<DD>delete the ending
</DL>
</DL>

<p>
<B>Step 4. Remove verbs endings:</B>
</p>

<DL><DD>
<DL>
<DT>(<I>a</I>)
If a length of the word is over 5 letters and the ending is one of the following:
<B><I>bym &nbsp; esz &nbsp; asz &nbsp; cie &nbsp; eść &nbsp; aść &nbsp; łem &nbsp; amy &nbsp; emy</I></B>
<DD>delete the ending
<DT>(<I>b</I>)
If a length of the word is over 3 letters and the ending is:
<B><I>aj</I></B>
<DD>delete the last letter
<DT>(<I>c</I>)
If a length of the word is over 3 letters and the ending is one of the following:
<B><I>ać &nbsp; em &nbsp; am &nbsp; ał &nbsp; ił &nbsp; ić &nbsp; ąc</I></B>
<DD>delete the last 2 letters
</DL>
</DL>

<p>
<B>Step 5. Remove adverbs endings:</B>
</p>

<DL><DD>
<DL>
<DT>(<I>a</I>)
If a length of the word is over 4 letters and the ending is one of the following:
<B><I>nie &nbsp; wie &nbsp; rze</I></B>
<DD>delete the the last 2 letters
</DL>
</DL>

<p>
<B>Step 6. Remove plural forms:</B>
</p>

<DL><DD>
<DL>
<DT>(<I>a</I>)
If a length of the word is over 4 letters and the ending is one of the following:
<B><I>ów &nbsp; om &nbsp; ami</I></B>
<DD>delete the the ending
</DL>
</DL>

<p>
<B>Step 7. Remove general endings:</B>
</p>

<DL><DD>
<DL>
<DT>(<I>a</I>)
If a length of the word is over 4 letters and the ending is one of the following:
<B><I>ia &nbsp; ie &nbsp; u &nbsp; ą &nbsp; i &nbsp; a &nbsp; ę &nbsp; y &nbsp; ę &nbsp; ł</I></B>
<DD>delete the the ending
</DL>
</DL>

<h2>The same algorithm in Snowball</h2>

[% highlight_file('polish') %]

[% footer %]
3 changes: 3 additions & 0 deletions index.tt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ speedily, and in any case they reserve the right to post their answers on snowba


<ul>
<li>
<strong>Dec 2021</strong> - Polish stemmer.
</li>
<li>
<strong>Nov 2021</strong> - <a href="download.html">Snowball 2.2.0 released!</a>
</li>
Expand Down