refactor: ♻️ format of threshold

This commit is contained in:
bubkoo 2020-09-27 21:59:20 +08:00
parent 2bfd89ddd8
commit bd25c96c13
3 changed files with 17 additions and 9 deletions

View File

@ -4,7 +4,6 @@
## Usage
Create `.github/workflows/potential-duplicates.yml` in the default branch:
```yaml
@ -23,12 +22,11 @@ jobs:
label: potential-duplicate
# Get issues with state to compare. Supported state: 'all', 'closed', 'open'.
state: all
# If similarity is higher than this threshold, issue will be marked as duplicate.
# If similarity is higher than this threshold([0,1]), issue will be marked as duplicate.
threshold: 0.6
# Comment to post when potential duplicates are detected.
comment: >
Potential duplicates:
{{#issues}}
Potential duplicates: {{#issues}}
- [#{{ number }}] {{ title }} ({{ accuracy }}%)
{{/issues}}
```

View File

@ -23,13 +23,17 @@ export namespace Action {
for (const issue of issues) {
const accuracy = Algo.compare(issue.title, title)
core.debug(`${issue.title} ~ ${title} = ${accuracy}`)
core.debug(
`${issue.title} ~ ${title} = ${parseFloat(
(accuracy * 100).toFixed(2),
)}%`,
)
if (accuracy >= threshold) {
duplicates.push({
number: issue.number,
title: issue.title,
accuracy: Math.round(accuracy * 100),
accuracy: parseFloat((accuracy * 100).toFixed(2)),
})
}
}

View File

@ -1,23 +1,29 @@
export namespace Dic {
export const excludes = [
'at',
'under',
'about',
'the',
'and',
'a',
'an',
'as',
'at',
'are',
'by',
'from',
'when',
'well',
'is',
'are',
'was',
'it',
'in',
'to',
'till',
'until',
'or',
'by',
'with',
'on',
'in',
'into',
'outo',
]