1

meta format change

This commit is contained in:
Alex Yatskov 2017-09-22 23:03:05 -07:00
parent a30edaf8bb
commit 7efb326fc1
2 changed files with 10 additions and 9 deletions

View File

@ -56,17 +56,18 @@ func (meta dbTagList) crush() dbRecordList {
return results
}
type dbFrequency struct {
type dbMeta struct {
Expression string
Count int
Mode string
Data interface{}
}
type dbFrequencyList []dbFrequency
type dbMetaList []dbMeta
func (freqs dbFrequencyList) crush() dbRecordList {
func (freqs dbMetaList) crush() dbRecordList {
var results dbRecordList
for _, f := range freqs {
results = append(results, dbRecord{f.Expression, f.Count})
results = append(results, dbRecord{f.Expression, f.Mode, f.Data})
}
return results

View File

@ -32,11 +32,11 @@ import (
const frequencyRevision = "frequency1"
func frequencyTermsExportDb(inputPath, outputPath, language, title string, stride int, pretty bool) error {
return frequncyExportDb(inputPath, outputPath, language, title, stride, pretty, "termfreq")
return frequncyExportDb(inputPath, outputPath, language, title, stride, pretty, "term_meta")
}
func frequencyKanjiExportDb(inputPath, outputPath, language, title string, stride int, pretty bool) error {
return frequncyExportDb(inputPath, outputPath, language, title, stride, pretty, "kanjifreq")
return frequncyExportDb(inputPath, outputPath, language, title, stride, pretty, "kanji_meta")
}
func frequncyExportDb(inputPath, outputPath, language, title string, stride int, pretty bool, key string) error {
@ -46,7 +46,7 @@ func frequncyExportDb(inputPath, outputPath, language, title string, stride int,
}
defer reader.Close()
var frequencies dbFrequencyList
var frequencies dbMetaList
for scanner := bufio.NewScanner(reader); scanner.Scan(); {
line := scanner.Text()
if strings.HasPrefix(line, "#") {
@ -64,7 +64,7 @@ func frequncyExportDb(inputPath, outputPath, language, title string, stride int,
continue
}
frequencies = append(frequencies, dbFrequency{expression, count})
frequencies = append(frequencies, dbMeta{expression, "freq", count})
}
if title == "" {