diff --git "a/data/words/v1/\345\212\250\350\257\215\350\257\215\345\272\223.xlsx" "b/data/words/v1/\345\212\250\350\257\215\350\257\215\345\272\223.xlsx" index db749c56d2267c95fd54566b75b88531f5662809..438462d612111e4369ece73879fa7fdfd9770e6a 100644 Binary files "a/data/words/v1/\345\212\250\350\257\215\350\257\215\345\272\223.xlsx" and "b/data/words/v1/\345\212\250\350\257\215\350\257\215\345\272\223.xlsx" differ diff --git "a/data/words/v1/\345\220\215\350\257\215\350\257\215\345\272\223.xlsx" "b/data/words/v1/\345\220\215\350\257\215\350\257\215\345\272\223.xlsx" index d6a1f35ae1f7e9236d4937d9f8f80d889b234e9a..cda06ee2e442a4c7ae6c341180a39a700859d96f 100644 Binary files "a/data/words/v1/\345\220\215\350\257\215\350\257\215\345\272\223.xlsx" and "b/data/words/v1/\345\220\215\350\257\215\350\257\215\345\272\223.xlsx" differ diff --git a/demo/article/article.txt b/demo/article/article.txt index 7aeb9c1fbd86da0af07578670f32acc84ed6d515..1bbc312ddcbe8f5b367a7965fa7174d53e12240b 100644 --- a/demo/article/article.txt +++ b/demo/article/article.txt @@ -1,3 +1,3 @@ -“秋天的天气”+(形容词-天气-秋季-好)、(形容词-天气-秋季-好),(形容词-外貌-女性)+(名词-姓+名词-名字=F)+(副词-程度副词)+(形容词做谓语-情绪-快乐),“因为”+(名词-称呼=F)+(动词-及物_名词-意愿)+“带她去”+(名词-地点-名山)+(动词-及物_名词-动作-眼部-中性)+(形容词-颜色-植物-树木)+(名词-植物-树木)+(连词-并列关系)+(形容词-颜色-植物-花卉)+(名词-植物-花卉)。 +难忘的秋游 -(S:形容词-外貌-女性)+(S:名词-姓+名词-名字=F)+(副词-程度副词)+(形容词做谓语-情绪-快乐),(副词-形容词做副词-情绪-快乐)+(动词-及物_名词-动作-手臂-亲切)+(形容词-性格-积极)+(S:名词-称呼=F)。 \ No newline at end of file +段落一:“秋天的天气”+(形容词-天气-秋季-好)、(形容词-天气-秋季-好),(形容词-外貌-女性)+(名词-姓+名词-名字=F)+(副词-程度副词)+(形容词做谓语-情绪-快乐),“因为”+(名词-称呼=F)+(动词-及物_名词-意愿)+“带她去”+(名词-地点-名山)+(动词-及物_名词-动作-眼部-中性)+(形容词-颜色-植物-树木)+(名词-植物-树木)+(连词-并列关系)+(形容词-颜色-植物-花卉)+(名词-植物-花卉)。(S:形容词-外貌-女性)+(S:名词-姓+名词-名字=F)+(副词-程度副词)+(形容词做谓语-情绪-快乐),(副词-形容词做副词-情绪-快乐)+(动词-及物_名词-动作-手臂-亲切)+(形容词-性格-积极)+(S:名词-称呼=F)。 \ No newline at end of file diff --git a/src/gen/excel.go b/src/gen/excel.go index 32785eec55647b9d3aeadf278268906932a9c08e..41bd641df74b449f75d76e20ed5b059e8ddd6c85 100644 --- a/src/gen/excel.go +++ b/src/gen/excel.go @@ -29,7 +29,7 @@ func GenerateFieldValuesFromExcel(filePath, sheet string, field *model.DefField) sheet = firstSheet } } else { // dir - ConvertExcelsToSQLiteIfNeeded(dbName, filePath) + ConvertWordExcelsToSQLiteIfNeeded(dbName, filePath) } list, selectCol := ReadDataFromSQLite(*field, dbName, sheet) @@ -166,7 +166,7 @@ func ConvertSingleExcelToSQLiteIfNeeded(dbName string, path string) (firstSheet return } -func ConvertExcelsToSQLiteIfNeeded(tableName string, dir string) { +func ConvertWordExcelsToSQLiteIfNeeded(tableName string, dir string) { if !isExcelChanged(dir) { return } @@ -175,8 +175,9 @@ func ConvertExcelsToSQLiteIfNeeded(tableName string, dir string) { fileUtils.GetFilesByExtInDir(dir, ".xlsx", &files) seq := 1 - ddlFields := make([]string, 0) insertSqls := make([]string, 0) + ddlFields := make([]string, 0) + ddlFields = append(ddlFields, " `词语` VARCHAR DEFAULT ''") colMap := map[string]bool{} for _, file := range files { @@ -230,12 +231,18 @@ func ReadDataFromSQLite(field model.DefField, dbName string, tableName string) ( } selectCol := field.Select + if vari.Def.Type == constant.ConfigTypeArticle { + selectCol = stringUtils.GetPinyin(selectCol) + } from := dbName if tableName != "" { from += "_" + tableName } where := field.Where + if vari.Def.Type == constant.ConfigTypeArticle { + where = stringUtils.GetPinyin(where) + } if where == "" { where = "1=1" } @@ -431,7 +438,9 @@ func importExcel(filePath, tableName string, seq *int, ddlFields, insertSqls *[] fileName := fileUtils.GetFileName(filePath) fileName = strings.TrimSuffix(fileName, "词库") - colPrefix := stringUtils.GetPinyin(fileName) + + colPrefix := fileName // stringUtils.GetPinyin(fileName) + *ddlFields = append(*ddlFields, " `" + colPrefix + "` VARCHAR DEFAULT ''") for rowIndex, sheet := range excel.GetSheetList() { rows, _ := excel.GetRows(sheet) @@ -441,6 +450,7 @@ func importExcel(filePath, tableName string, seq *int, ddlFields, insertSqls *[] colDefine := "" colList := make([]string, 0) + colList = append(colList, "`" + colPrefix + "`") colCount := 0 index := 0 @@ -451,19 +461,17 @@ func importExcel(filePath, tableName string, seq *int, ddlFields, insertSqls *[] } colCount++ - colName := stringUtils.GetPinyin(val) - - if colIndex == 0 && colName != "ci" { - colName = "ci" - } - if colName != "ci" { - colName = colPrefix + "_" + colName - } + colName := val // stringUtils.GetPinyin(val) if (*colMap)[colName] == false { colType := "VARCHAR" colDefine = " " + "`" + colName + "` " + colType + " DEFAULT ''" - *ddlFields = append(*ddlFields, colDefine) + + if colIndex == 0 { + colName = "词语" + } else { // first already added + *ddlFields = append(*ddlFields, colDefine) + } (*colMap)[colName] = true } @@ -480,6 +488,7 @@ func importExcel(filePath, tableName string, seq *int, ddlFields, insertSqls *[] valListItem := make([]string, 0) valListItem = append(valListItem, strconv.Itoa(*seq)) + valListItem = append(valListItem, "'y'") *seq += 1 for i := 0; i < colCount; i++ { diff --git a/src/service/article.go b/src/service/article.go index 1ddc4cde55d95deb917769f306213fb911d3e25b..d06f13882d5ad9355347a63a976ca9c4ef9363c2 100644 --- a/src/service/article.go +++ b/src/service/article.go @@ -36,12 +36,12 @@ func ConvertArticle(src, dist string) { files = append(files, pth) if dist == "" { - dist = path.Dir(pth) + dist = fileUtils.AddSepIfNeeded(path.Dir(pth)) } } else { fileUtils.GetFilesInDir(src, ".txt", &files) if dist == "" { - dist = src + dist = fileUtils.AddSepIfNeeded(src) } } diff --git a/test/article/generate_yaml_test.go b/test/article/generate_yaml_test.go deleted file mode 100644 index 06ab7d0f9a35a7d1070711496d6ca1cb892a258f..0000000000000000000000000000000000000000 --- a/test/article/generate_yaml_test.go +++ /dev/null @@ -1 +0,0 @@ -package main diff --git a/yaml/article/chinese/jixuwen.1.yaml b/yaml/article/chinese/jixuwen.1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391