Example #1
0
func wordcount(filename interface{}, output chan interface{}) {
	results := map[string]int{}
	wordsRE := regexp.MustCompile(`[A-Za-z0-9_]*`)
	for line := range fileiter.EachLine(filename.(string)) {
		for _, match := range wordsRE.FindAllString(line, -1) {
			results[match]++
		}
	}
	output <- results
}
func countwords(filename interface{}, output chan interface{}) {
	results := map[string]int{}
	wordsRE := regexp.MustCompile(`[A-Za-z0-9_]*`)
	for line := range fileiter.EachLine(filename.(string)) {
		for _, match := range wordsRE.FindAllString(line, -1) {
			results[match]++
		}
	}

	//fmt.Println("keyvalues", results);
	fmt.Println("-")

	output <- results
}