forked from psankar/korkai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suffix-trimmer.go
44 lines (40 loc) · 1.12 KB
/
suffix-trimmer.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
package main
import (
"bufio"
"io/ioutil"
"log"
"os"
"strings"
)
func main() {
content, err := ioutil.ReadFile(os.Args[1])
if err != nil {
log.Fatal(err)
}
words := strings.Split(string(content), "\n")
if words[len(words)-1] == "" {
words = words[:len(words)-1]
}
f, err := os.Create("SuffixTrimmed.txt")
if err != nil {
log.Fatal(err)
}
w := bufio.NewWriter(f)
for _, word := range words {
if !strings.ContainsAny(word, "+♥ஃ௦௪௫௰௯௩௬௨௲௵௴௷௱+$ஜஷஸஹ0123456789abcdefghijklmnopqrstuvxyz~`-´௳௶௸௹௺") {
// Skip words ending in some letters
suffixes := []string{"க்", "ங்", "ச்", "ஞ்", "ட்", "த்", "ந்", "ப்", "வ்", "ற்", "னும்", "னின்", "னிடம்", "ரிடம்", "ரின்", "கின்றன", "கின்ற", "லும்", "வும்", "ளில்", "ளுடன்"}
hasSuffix := false
for _, suffix := range suffixes {
if strings.HasSuffix(word, suffix) {
hasSuffix = true
break
}
}
if !hasSuffix {
w.WriteString(word + "\n")
}
}
}
w.Flush()
}