perf: better keyword time complexity
This commit is contained in:
parent
01949f136a
commit
a5680bb3bc
|
@ -102,19 +102,15 @@ def get_executor_with(
|
|||
def fix_keyword(
|
||||
keyword_config: task.ParserKeyword, keyword_parser: result.Parser
|
||||
) -> None:
|
||||
keyword_weight: List[result.KeywordConfig] = []
|
||||
unique_weight = list(set(keyword_config.weight))
|
||||
for score in unique_weight:
|
||||
keyword_weight.append(result.KeywordConfig(keywords=[], score=score))
|
||||
|
||||
for idx, score in enumerate(unique_weight):
|
||||
for idx_, score_ in enumerate(keyword_config.weight):
|
||||
if score == score_:
|
||||
keyword_weight[idx].keywords.append(keyword_config.keyword[idx_])
|
||||
else:
|
||||
continue
|
||||
|
||||
keyword_parser.with_ = result.KeywordMatchConfig(matches=keyword_weight)
|
||||
score_groups: Dict[int, List[str]] = {}
|
||||
for keyword, score in zip(keyword_config.keyword, keyword_config.weight):
|
||||
score_groups.setdefault(score, []).append(keyword)
|
||||
keyword_parser.with_ = result.KeywordMatchConfig(
|
||||
matches=[
|
||||
result.KeywordConfig(keywords=keywords, score=score)
|
||||
for score, keywords in score_groups.items()
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def fix_result_detail(
|
||||
|
|
|
@ -249,17 +249,17 @@
|
|||
"name": "keyword",
|
||||
"with": {
|
||||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"recommended"
|
||||
],
|
||||
"score": 10
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"max"
|
||||
],
|
||||
"score": 20
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"recommended"
|
||||
],
|
||||
"score": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -349,20 +349,6 @@
|
|||
"name": "clangtidy",
|
||||
"with": {
|
||||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"readability-function-size"
|
||||
],
|
||||
"score": 10
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"codequality-no-global-variables",
|
||||
"codequality-no-header-guard",
|
||||
"codequality-no-fflush-stdin"
|
||||
],
|
||||
"score": 20
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"codequality-unchecked-malloc-result",
|
||||
|
@ -381,6 +367,20 @@
|
|||
],
|
||||
"score": 5
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"codequality-no-global-variables",
|
||||
"codequality-no-header-guard",
|
||||
"codequality-no-fflush-stdin"
|
||||
],
|
||||
"score": 20
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"readability-function-size"
|
||||
],
|
||||
"score": 10
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"readability-misleading-indentation"
|
||||
|
@ -477,6 +477,12 @@
|
|||
"name": "cppcheck",
|
||||
"with": {
|
||||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"error"
|
||||
],
|
||||
"score": 15
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"warning",
|
||||
|
@ -485,12 +491,6 @@
|
|||
"style"
|
||||
],
|
||||
"score": 5
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"error"
|
||||
],
|
||||
"score": 15
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -618,9 +618,9 @@
|
|||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"build"
|
||||
"runtime"
|
||||
],
|
||||
"score": 10
|
||||
"score": 5
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
|
@ -630,9 +630,9 @@
|
|||
},
|
||||
{
|
||||
"keywords": [
|
||||
"runtime"
|
||||
"build"
|
||||
],
|
||||
"score": 5
|
||||
"score": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -77,20 +77,6 @@
|
|||
"name": "clangtidy",
|
||||
"with": {
|
||||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"readability-function-size"
|
||||
],
|
||||
"score": 10
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"codequality-no-global-variables",
|
||||
"codequality-no-header-guard",
|
||||
"codequality-no-fflush-stdin"
|
||||
],
|
||||
"score": 20
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"codequality-unchecked-malloc-result",
|
||||
|
@ -109,6 +95,20 @@
|
|||
],
|
||||
"score": 5
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"codequality-no-global-variables",
|
||||
"codequality-no-header-guard",
|
||||
"codequality-no-fflush-stdin"
|
||||
],
|
||||
"score": 20
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"readability-function-size"
|
||||
],
|
||||
"score": 10
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"readability-misleading-indentation"
|
||||
|
|
|
@ -70,6 +70,12 @@
|
|||
"name": "cppcheck",
|
||||
"with": {
|
||||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"error"
|
||||
],
|
||||
"score": 15
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"warning",
|
||||
|
@ -78,12 +84,6 @@
|
|||
"style"
|
||||
],
|
||||
"score": 5
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"error"
|
||||
],
|
||||
"score": 15
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -71,9 +71,9 @@
|
|||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"build"
|
||||
"runtime"
|
||||
],
|
||||
"score": 10
|
||||
"score": 5
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
|
@ -83,9 +83,9 @@
|
|||
},
|
||||
{
|
||||
"keywords": [
|
||||
"runtime"
|
||||
"build"
|
||||
],
|
||||
"score": 5
|
||||
"score": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -72,17 +72,17 @@
|
|||
"name": "keyword",
|
||||
"with": {
|
||||
"matches": [
|
||||
{
|
||||
"keywords": [
|
||||
"recommended"
|
||||
],
|
||||
"score": 10
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"max"
|
||||
],
|
||||
"score": 20
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"recommended"
|
||||
],
|
||||
"score": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user