-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstep1a.go
50 lines (43 loc) · 1.14 KB
/
step1a.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package gwizo
import "strings"
/*Step1a from "An algorithm for suffix stripping".
Deals with plurals and past participles. The subsequent steps
are much more straightforward.
From the paper:
SSES -> SS caresses -> caress
IES -> I ponies -> poni
ties -> ti
SS -> SS caress -> caress
S -> cats -> cat
*/
func Step1a(word string) string {
// For SSES suffix. SSES -> SS
sses := strings.HasSuffix(word, "sses")
if sses {
pre := strings.TrimSuffix(word, "sses")
word = pre + "ss"
return word
}
// For IES suffix. IES -> I
ies := strings.HasSuffix(word, "ies")
if ies {
pre := strings.TrimSuffix(word, "ies")
word = pre + letterI
return word
}
// For SS suffix. SS -> SS
ss := strings.HasSuffix(word, "ss")
if ss {
pre := strings.TrimSuffix(word, "ss")
word = pre + "ss"
return word
}
// For S suffix. S ->
s := strings.HasSuffix(word, "s")
if s {
pre := strings.TrimSuffix(word, "s")
word = pre
return word
}
return word
}