func dirHod(puth, need string, str []string) []string { files, _ := ioutil.ReadDir(puth) //fmt.Println(files) for _, f := range files { if f.IsDir() { str = dirHod(puth+f.Name()+"/", need, str) } else { //fmt.Println(path.Ext(f.Name())) if path.Ext(f.Name()) == need { str = append(str, puth+f.Name()) } } } return str }
func createMarkerSentense() { morfEng.InitEngl() files, _ := ioutil.ReadDir("file/exemple") nal := map[string]map[string][]string{} buf := bytes.NewBuffer(nil) for _, f := range files { files1, _ := ioutil.ReadDir("file/exemple/" + f.Name()) nal[f.Name()] = map[string][]string{} for _, f1 := range files1 { nal[f.Name()][f1.Name()] = []string{} buf.Reset() file, _ := os.Open("file/exemple/" + f.Name() + "/" + f1.Name()) // Error handling elided for brevity. io.Copy(buf, file) // Error handling elided for brevity. file.Close() arraySentense := regexp.MustCompile(`\n`).Split(buf.String(), -1) for _, val := range arraySentense { val = strings.Replace(val, "’", "'", -1) nal[f.Name()][f1.Name()] = append(nal[f.Name()][f1.Name()], val) } } } for k, f := range nal { fmt.Println(k) for k1, f1 := range f { fmt.Printf("\t%s\n", k1) for _, f2 := range f1 { fmt.Print("\t\t") fmt.Println(morfEng.getWordWithoutOmonemii(f2)) //for _, v := range morfEng.Graf.PrepereSentense(f2){ // fmt.Printf("\t\t%s\n", porter2.Stem((v))) //} fmt.Printf("\t\t%s\n", f2) } } } }