Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zendata
提交
27d74ce0
Z
zendata
项目概览
易企天创
/
zendata
8 个月 前同步成功
通知
17
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
27d74ce0
编写于
9月 16, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
split by full stop and new line
上级
5dbb81ea
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
87 addition
and
13 deletion
+87
-13
demo/article/article.txt
demo/article/article.txt
+3
-1
src/gen/excel.go
src/gen/excel.go
+1
-1
src/gen/list.go
src/gen/list.go
+5
-0
src/gen/parser.go
src/gen/parser.go
+17
-0
src/model/definition.go
src/model/definition.go
+0
-1
src/service/article.go
src/service/article.go
+61
-10
未找到文件。
demo/article/article.txt
浏览文件 @
27d74ce0
难忘的秋游
段落一:“秋天的天气”+(形容词-天气-秋季-好)、(形容词-天气-秋季-好),(形容词-外貌-女性)+(名词-姓+名词-名字=F)+(副词-程度副词)+(形容词做谓语-情绪-快乐),“因为”+(名词-称呼=F)+(动词-及物_名词-意愿)+“带她去”+(名词-地点-名山)+(动词-及物_名词-动作-眼部-中性)+(形容词-颜色-植物-树木)+(名词-植物-树木)+(连词-并列关系)+(形容词-颜色-植物-花卉)+(名词-植物-花卉)。(S:形容词-外貌-女性)+(S:名词-姓+名词-名字=F)+(副词-程度副词)+(形容词做谓语-情绪-快乐),(副词-形容词做副词-情绪-快乐)+(动词-及物_名词-动作-手臂-亲切)+(形容词-性格-积极)+(S:名词-称呼=F)+ “结尾。”
\ No newline at end of file
段落一:(S:名词-称呼=F)+ “结尾。”
段落二:“第二段内容”
\ No newline at end of file
src/gen/excel.go
浏览文件 @
27d74ce0
...
...
@@ -167,7 +167,7 @@ func ConvertSingleExcelToSQLiteIfNeeded(dbName string, path string) (firstSheet
func
ConvertWordExcelsToSQLiteIfNeeded
(
tableName
string
,
dir
string
)
{
if
!
isExcelChanged
(
dir
)
{
//
return
return
}
files
:=
make
([]
string
,
0
)
...
...
src/gen/list.go
浏览文件 @
27d74ce0
...
...
@@ -32,6 +32,11 @@ func CreateListFieldValues(field *model.DefField, fieldValue *model.FieldWithVal
func
CreateFieldValuesFromList
(
field
*
model
.
DefField
,
fieldValue
*
model
.
FieldWithValues
)
{
rang
:=
field
.
Range
if
rang
==
""
{
fieldValue
.
Values
=
append
(
fieldValue
.
Values
,
""
)
return
}
rangeSections
:=
ParseRangeProperty
(
rang
)
// 1
index
:=
0
...
...
src/gen/parser.go
浏览文件 @
27d74ce0
...
...
@@ -53,6 +53,12 @@ func ParseRangeProperty(rang string) []string {
func
ParseDesc
(
desc
string
)
(
items
[]
string
)
{
desc
=
strings
.
TrimSpace
(
desc
)
desc
=
strings
.
Trim
(
desc
,
","
)
if
desc
==
""
{
items
=
append
(
items
,
desc
)
return
}
runeArr
:=
[]
rune
(
desc
)
if
runeArr
[
0
]
==
constant
.
Backtick
&&
runeArr
[
len
(
runeArr
)
-
1
]
==
constant
.
Backtick
{
// `xxx`
...
...
@@ -78,6 +84,12 @@ func ParseDesc(desc string) (items []string) {
*/
func
ParseRangeSection
(
item
string
)
(
entry
string
,
step
string
,
repeat
int
)
{
item
=
strings
.
TrimSpace
(
item
)
if
item
==
""
{
repeat
=
1
return
}
runeArr
:=
[]
rune
(
item
)
if
(
runeArr
[
0
]
==
constant
.
Backtick
&&
runeArr
[
len
(
runeArr
)
-
1
]
==
constant
.
Backtick
)
||
// `xxx`
(
string
(
item
[
0
])
==
string
(
constant
.
LeftBrackets
)
&&
// (xxx)
...
...
@@ -115,6 +127,11 @@ func ParseRangeSection(item string) (entry string, step string, repeat int) {
func
ParseRangeSectionDesc
(
str
string
)
(
typ
string
,
desc
string
)
{
desc
=
strings
.
TrimSpace
(
str
)
if
desc
==
""
{
typ
=
"literal"
return
}
if
stringUtils
.
EndWith
(
desc
,
".yaml"
)
{
// refer to another yaml file
typ
=
"yaml"
return
...
...
src/model/definition.go
浏览文件 @
27d74ce0
...
...
@@ -123,5 +123,4 @@ type DefFieldExport struct {
Where
string
`yaml:"where"`
Rand
bool
`yaml:"rand"`
Limit
int
`yaml:"limit"`
Range
string
`yaml:"range"`
}
\ No newline at end of file
src/service/article.go
浏览文件 @
27d74ce0
...
...
@@ -51,7 +51,7 @@ func ConvertArticle(src, dist string) {
}
func
convertToYaml
(
article
,
filePath
string
)
(
content
string
)
{
sections
:=
parseSections
(
article
)
sections
,
_
:=
parseSections
(
article
)
conf
:=
createDef
(
constant
.
ConfigTypeArticle
,
table
,
filePath
)
...
...
@@ -59,6 +59,8 @@ func convertToYaml(article, filePath string) (content string) {
for
index
,
section
:=
range
sections
{
tye
:=
section
[
"type"
]
val
:=
section
[
"val"
]
parag
:=
section
[
"parag"
]
sent
:=
section
[
"sent"
]
if
tye
==
"exp"
{
fields
:=
createFields
(
index
,
prefix
,
val
)
...
...
@@ -68,11 +70,18 @@ func convertToYaml(article, filePath string) (content string) {
}
else
{
prefix
+=
val
if
prefix
!=
""
&&
index
==
len
(
sections
)
-
1
{
field
:=
model
.
DefFieldExport
{}
field
.
Range
=
prefix
if
parag
==
"true"
{
field
:=
model
.
DefFieldExport
{
Field
:
strconv
.
Itoa
(
index
),
Prefix
:
prefix
}
conf
.
XFields
=
append
(
conf
.
XFields
,
field
)
prefix
=
""
}
else
if
sent
==
"true"
{
field
:=
model
.
DefFieldExport
{
Field
:
strconv
.
Itoa
(
index
),
Prefix
:
prefix
}
conf
.
XFields
=
append
(
conf
.
XFields
,
field
)
prefix
=
""
}
else
if
prefix
!=
""
&&
index
==
len
(
sections
)
-
1
{
// last section
field
:=
model
.
DefFieldExport
{
Field
:
strconv
.
Itoa
(
index
),
Prefix
:
prefix
}
conf
.
XFields
=
append
(
conf
.
XFields
,
field
)
prefix
=
""
}
}
}
...
...
@@ -142,13 +151,16 @@ func createFields(index int, prefix, exp string) (fields []model.DefFieldExport)
return
}
func
parseSections
(
content
string
)
(
sections
[]
map
[
string
]
string
)
{
func
parseSections
(
content
string
)
(
sections
[]
map
[
string
]
string
,
division
[][]
int
)
{
strStart
:=
false
expStart
:=
false
content
=
strings
.
TrimSpace
(
content
)
runeArr
:=
[]
rune
(
content
)
//parag := 0
//sent := 0
section
:=
""
for
i
:=
0
;
i
<
len
(
runeArr
);
i
++
{
item
:=
runeArr
[
i
]
...
...
@@ -158,6 +170,11 @@ func parseSections(content string) (sections []map[string]string) {
if
isCouple
{
section
+=
duplicateStr
i
+=
1
if
i
==
len
(
runeArr
)
-
1
{
addSection
(
section
,
"str"
,
&
sections
)
}
}
else
if
strStart
&&
str
==
strRight
{
// str close
addSection
(
section
,
"str"
,
&
sections
)
...
...
@@ -184,11 +201,37 @@ func parseSections(content string) (sections []map[string]string) {
section
=
""
}
else
{
section
+=
str
}
//if i == len(runeArr) - 1 && len(section) > 0 {
// addSection(section, "str", §ions)
//}
if
str
==
"。"
{
if
i
<
len
(
runeArr
)
&&
string
(
runeArr
[
i
+
1
])
==
strRight
{
i
+=
1
}
addSection
(
section
,
"str"
,
&
sections
)
strStart
=
false
expStart
=
false
section
=
""
}
else
if
str
==
"
\n
"
{
// get all \n
for
j
:=
i
+
1
;
j
<
len
(
runeArr
);
j
++
{
if
string
(
runeArr
[
j
])
==
"
\n
"
{
section
+=
str
i
=
j
}
else
{
break
}
}
addSection
(
section
,
"str"
,
&
sections
)
strStart
=
false
expStart
=
false
section
=
""
}
else
if
i
==
len
(
runeArr
)
-
1
{
addSection
(
section
,
"str"
,
&
sections
)
}
}
}
return
...
...
@@ -199,6 +242,14 @@ func addSection(str, typ string, arr *[]map[string]string) {
mp
[
"type"
]
=
typ
mp
[
"val"
]
=
str
runeArr
:=
[]
rune
(
str
)
end
:=
runeArr
[
len
(
runeArr
)
-
1
]
if
string
(
end
)
==
"
\n
"
{
mp
[
"parag"
]
=
"true"
}
else
if
string
(
end
)
==
"。"
{
mp
[
"sent"
]
=
"true"
}
*
arr
=
append
(
*
arr
,
mp
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录