func main() { out := bufio.NewWriter(os.Stdout) defer out.Flush() testFile, err := readFile("test.txt") if err != nil { panic(err) } reg := regexp.MustCompile("[\\w]+") count := 0 for _, line := range testFile { //words := strings.Split(line, " ") words := reg.FindAllString(line, -1) for _, word := range words { porter := string(stemmer.Stem([]byte(word))) paice := paicehusk.DefaultRules.Stem(word) if porter != paice { count++ out.WriteString(word + " ") out.WriteString(porter + " ") out.WriteString(paice + "\n") } } } out.WriteString(fmt.Sprintf("%v", count)) }
func main() { in := bufio.NewReader(os.Stdin) out := bufio.NewWriter(os.Stdout) defer out.Flush() for word, err := in.ReadSlice('\n'); err == nil; word, err = in.ReadSlice('\n') { out.Write(stemmer.Stem(word)) out.WriteString("\n") } }