From b955279c9c97390fbdc284b4260cf7fa284a3bba Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Sat, 14 Dec 2019 23:45:47 +0800 Subject: [PATCH] feat: add basic keywords --- src/domain/concept_analyser.go | 52 ++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/domain/concept_analyser.go b/src/domain/concept_analyser.go index 2aa7148..41c9a1a 100644 --- a/src/domain/concept_analyser.go +++ b/src/domain/concept_analyser.go @@ -7,14 +7,13 @@ import ( ) type ConceptAnalyser struct { - } func NewConceptAnalyser() ConceptAnalyser { return *&ConceptAnalyser{} } -func (c ConceptAnalyser) run() { +func (c ConceptAnalyser) run() { } @@ -33,8 +32,51 @@ func buildMethodsFromDeps(clzs []models.JClassNode) { } } - camelcase := support.SegmentConceptCamelcase(methodsName) + words := support.SegmentConceptCamelcase(methodsName) + + words = removeNormalWords(words) + + wordCounts := support.RankByWordCount(words) + for _, word := range wordCounts[0:20] { + fmt.Println(word.Key, word.Value) + } +} + +var normalWords = []string{ + "get", + "create", + "update", + "delete", + "save", + + "exist", + "find", + "new", + "parse", + + "set", + "get", + + "type", + + "all", + "by", + "id", + "is", + "of", + "not", + "with", + "main", +} + +func removeNormalWords(words map[string]int) map[string]int { + var newWords = words + for _, normalWord := range normalWords { + if newWords[normalWord] > 0 { + delete(newWords, normalWord) + } + } - count := support.RankByWordCount(camelcase) - fmt.Println(count) + fmt.Println(newWords) + return newWords } -- GitLab