Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
43ce7b5a
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
43ce7b5a
编写于
12月 22, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: update concept output
上级
42001fb1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
24 deletion
+52
-24
README.md
README.md
+15
-19
cmd/concept.go
cmd/concept.go
+12
-4
core/domain/concept/concept_analyser.go
core/domain/concept/concept_analyser.go
+11
-1
core/domain/concept/concept_segmenter.go
core/domain/concept/concept_segmenter.go
+14
-0
未找到文件。
README.md
浏览文件 @
43ce7b5a
...
...
@@ -196,25 +196,21 @@ coca concept
Results Examples:
```
product 874
time 541
member 405
like 404
example 371
order 328
primary 288
criterion 222
price 214
selective 212
promotion 198
list 196
category 184
icon 160
note 159
pic 147
point 143
brand 131
receiver 121
+------------------+--------+
| WORDS | COUNTS |
+------------------+--------+
| context | 590 |
| resolve | 531 |
| path | 501 |
| content | 423 |
| code | 416 |
| resource | 373 |
| property | 372 |
| session | 364 |
| attribute | 349 |
| properties | 343 |
| headers | 330 |
+------------------+--------+
```
### Count Refs
...
...
cmd/concept.go
浏览文件 @
43ce7b5a
package
cmd
import
(
"encoding/json"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/config"
"github.com/phodal/coca/core/domain/concept"
"github.com/phodal/coca/core/models"
.
"github.com/phodal/coca/core/support"
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"log"
"os"
"strconv"
)
var
parsedDeps
[]
models
.
JClassNode
...
...
@@ -27,14 +29,20 @@ var conceptCmd = &cobra.Command{
log
.
Fatal
(
"lost file:"
+
dependence
)
}
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
wordCounts
:=
analyser
.
Analysis
(
&
parsedDeps
)
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetHeader
([]
string
{
"Words"
,
"Counts"
})
for
_
,
word
:=
range
wordCounts
{
if
word
.
Value
>
0
{
fmt
.
Println
(
word
.
Key
,
word
.
Value
)
table
.
Append
([]
string
{
word
.
Key
,
strconv
.
Itoa
(
word
.
Value
)}
)
}
}
table
.
Render
()
}
},
}
...
...
core/domain/concept/concept_analyser.go
浏览文件 @
43ce7b5a
...
...
@@ -46,6 +46,7 @@ var itStopWords = []string{
"update"
,
"delete"
,
"save"
,
"post"
,
"add"
,
"remove"
,
...
...
@@ -105,8 +106,17 @@ var itStopWords = []string{
"message"
,
"factory"
,
"error"
,
"error"
,
"error
s
"
,
"exception"
,
"null"
,
"string"
,
"init"
,
"data"
,
"hash"
,
"convert"
,
"size"
,
"build"
,
"return"
,
}
func
removeNormalWords
(
words
map
[
string
]
int
)
map
[
string
]
int
{
...
...
core/domain/concept/concept_segmenter.go
浏览文件 @
43ce7b5a
...
...
@@ -2,6 +2,7 @@ package concept
import
(
"github.com/iancoleman/strcase"
"regexp"
"strings"
)
...
...
@@ -25,6 +26,9 @@ func SegmentConceptCamelcase(methodsName []string) map[string]int {
delimited
:=
strcase
.
ToDelimited
(
name
,
'.'
)
split
:=
strings
.
Split
(
delimited
,
"."
)
for
_
,
word
:=
range
split
{
if
FilterString
(
word
)
==
""
{
continue
}
if
strMap
[
word
]
==
0
{
strMap
[
word
]
=
1
}
else
{
...
...
@@ -36,3 +40,13 @@ func SegmentConceptCamelcase(methodsName []string) map[string]int {
return
strMap
}
func
FilterString
(
str
string
)
string
{
var
digitCheck
=
regexp
.
MustCompile
(
`^[0-9]+$`
)
if
digitCheck
.
MatchString
(
str
)
{
return
""
}
return
strings
.
TrimSpace
(
str
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录