Added classifier to the sequence of strategies

This commit is contained in:
Manuel Carmona
2017-05-25 12:34:32 +02:00
parent fcf30a07c8
commit f8b8f7f5c4
9 changed files with 209 additions and 77 deletions

View File

@ -16,6 +16,8 @@ import (
"gopkg.in/src-d/simple-linguist.v1/internal/tokenizer"
)
const samplesSubDir = "filenames"
type samplesFrequencies struct {
LanguageTotal int `json:"language_total,omitempty"`
Languages map[string]int `json:"languages,omitempty"`
@ -37,11 +39,7 @@ func Frequencies(samplesDir, frequenciesTmplPath, frequenciesTmplName, commit, o
return err
}
if err := formatedWrite(outPath, buf.Bytes()); err != nil {
return err
}
return nil
return formatedWrite(outPath, buf.Bytes())
}
func getFrequencies(samplesDir string) (*samplesFrequencies, error) {
@ -98,8 +96,6 @@ func getFrequencies(samplesDir string) (*samplesFrequencies, error) {
}
func getSamples(samplesDir string, langDir os.FileInfo) ([]string, error) {
const subDir = "filenames"
samples := []string{}
path := filepath.Join(samplesDir, langDir.Name())
entries, err := ioutil.ReadDir(path)
@ -112,7 +108,7 @@ func getSamples(samplesDir string, langDir os.FileInfo) ([]string, error) {
samples = append(samples, filepath.Join(path, entry.Name()))
}
if entry.IsDir() && entry.Name() == subDir {
if entry.IsDir() && entry.Name() == samplesSubDir {
subSamples, err := getSubSamples(samplesDir, langDir.Name(), entry)
if err != nil {
return nil, err