[Snowball-discuss] Tcl binding for Snowball stemmers
Michael Schlenker
schlenk@uni-oldenburg.de
Thu, 01 Aug 2002 14:26:25 +0200
Hi all,
i just built a small tcl binding for snowball stemmers.
You can build an tcl extension (.dll / .so) with it to use the ANSI C
stemmers in tcl, at the moment only 4 are included (porter1 porter2
german french), but others can be added easily.
I've uploaded it to patches at www.sf.net/projects/snowball, so if you
want to take a look...
Michael Schlenker
------------
At little toy app for the binding (run it with wish or tclkit):
#!/bin/sh
# \
exec wish "$0" "$@"
package require Tk
package require Tclsnowball
proc do_stem {word} {
set ::result1 [::snowball::stem porter $word]
set ::result2 [::snowball::stem porter2 $word]
set ::result3 [::snowball::stem german $word]
set ::result4 [::snowball::stem french $word]
}
proc stemtest {root} {
if {$root == "."} {
set f .stemtest
} else {
set f ${root}.stemtest
}
frame $f -bg white
label $f.wlabel -text "Word to stem:" -background white -justify
left
entry $f.word -textvariable ::word -width 20 -background white \
-foreground black
button $f.stemit -text "Stem" -command {do_stem $word}
label $f.rlabel1 -text "Porter 1 Stemmed word:" -background
white \
-justify left
entry $f.result1 -textvariable ::result1 -width 20 \
-background white \
-foreground darkblue
label $f.rlabel2 -text "Porter 2 Stemmed word:" -background
white \
-justify left
entry $f.result2 -textvariable ::result2 -width 20 \
-background white \
-foreground darkblue
label $f.rlabel3 -text "German Stemmed word:" -background white
\
-justify left
entry $f.result3 -textvariable ::result3 -width 20 \
-background white \
-foreground darkblue
label $f.rlabel4 -text "French Stemmed word:" -background white
\
-justify left
entry $f.result4 -textvariable ::result4 -width 20 \
-background white \
-foreground darkblue
button $f.quit -text "Quit" -command {exit}
grid $f.wlabel $f.word $f.stemit -sticky ns -pady 4
grid $f.rlabel1 $f.result1 -sticky news -pady 4
grid $f.rlabel2 $f.result2 -sticky news -pady 4
grid $f.rlabel3 $f.result3 -sticky news -pady 4
grid $f.rlabel4 $f.result4 -sticky news -pady 4
grid $f.quit -sticky ew -column 3
return $f
}
set w [stemtest .]
wm title . "Stemming test"
pack $w
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Snowball-discuss mailing list
Snowball-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/snowball-discuss