-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstep3.go
89 lines (79 loc) · 2.01 KB
/
step3.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package gwizo
import "strings"
/*Step3 from "An algorithm for suffix stripping".
From the paper:
Step 3
(m>0) ICATE -> IC triplicate -> triplic
(m>0) ATIVE -> formative -> form
(m>0) ALIZE -> AL formalize -> formal
(m>0) ICITI -> IC electriciti -> electric
(m>0) ICAL -> IC electrical -> electric
(m>0) FUL -> hopeful -> hope
(m>0) NESS -> goodness -> good
*/
func Step3(word string) string {
// For ICATE suffix. ICATE -> IC
icate := strings.HasSuffix(word, "icate")
if icate {
pre := strings.TrimSuffix(word, "icate")
if MeasureGreaterThan0(pre) {
word = pre + "ic"
return word
}
}
// For ATIVE suffix. ATIVE ->
ative := strings.HasSuffix(word, "ative")
if ative {
pre := strings.TrimSuffix(word, "ative")
if MeasureGreaterThan0(pre) {
word = pre
return word
}
}
// For ALIZE suffix. ALIZE -> AL
alize := strings.HasSuffix(word, "alize")
if alize {
pre := strings.TrimSuffix(word, "alize")
if MeasureGreaterThan0(pre) {
word = pre + "al"
return word
}
}
// For ICITI suffix. ICITI -> IC
iciti := strings.HasSuffix(word, "iciti")
if iciti {
pre := strings.TrimSuffix(word, "iciti")
if MeasureGreaterThan0(pre) {
word = pre + "ic"
return word
}
}
// For ICAL suffix. ICAL -> IC
ical := strings.HasSuffix(word, "ical")
if ical {
pre := strings.TrimSuffix(word, "ical")
if MeasureGreaterThan0(pre) {
word = pre + "ic"
return word
}
}
// For FUL suffix. FUL ->
ful := strings.HasSuffix(word, "ful")
if ful {
pre := strings.TrimSuffix(word, "ful")
if MeasureGreaterThan0(pre) {
word = pre
return word
}
}
// For NESS suffix. NESS ->
ness := strings.HasSuffix(word, "ness")
if ness {
pre := strings.TrimSuffix(word, "ness")
if MeasureGreaterThan0(pre) {
word = pre
return word
}
}
return word
}