Skip to content

Commit

Permalink
fix/update (annotation-metrics): self order adjust/improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Oct 7, 2024
1 parent c07b3cb commit ebde53c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/adonisjs/public/editor/annotate/js/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,23 @@ class AnnotationMetrics {
let catG = null
for (let i = 0; i < sortedL.length; i++) {
if (sortedL[i][0] === cat) {
const quantity = (sortedL[i].length === 2) ? 1 : sortedL[i][2]
// if any element in the previous position is not in the same category
if (prev == -1 || (sortedL[prev][0] !== cat &&
(prevG == -1 || sortedL[prev][1] > sortedL[prevG][1]))) {
catG = [cat, sortedL[i][1], 1] // new category grouping
if ((prev === -1 && prevG === -1) || // first appearance
(prev !== -1 && // has an element in a previous position
(sortedL[prev][0] !== cat && // not in the same category
(prevG === -1 || // has no previous element of the category
// previous in the category precedes last annotation position
sortedL[prev][1] > sortedL[prevG][1])))) {
catG = [cat, sortedL[i][1], quantity] // new category grouping
grouped.push(catG)
} else {
catG[2]++
catG[2] += quantity
}
prevG = i
}
// last distinct position in the sequence
if (i+1 == sortedL.length || sortedL[i+1][1] !== sortedL[i][1])
if (i+1 === sortedL.length || sortedL[i+1][1] !== sortedL[i][1])
prev = i
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/adonisjs/public/editor/annotate/metrics/test-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ function present (output) {
present(JSON.stringify(AnnotationMetrics.i._selfOrderCount(
[[1, 10], [2, 20], [1, 20], [2, 30]], present)))
present(JSON.stringify(AnnotationMetrics.i._selfOrderCount(
[[1, 10], [2, 20], [1, 25], [2, 30]], present)))
[[1, 10, 2], [2, 20, 3], [1, 25, 5], [2, 30, 1]], present)))
present(JSON.stringify(AnnotationMetrics.i._selfOrderCount(
[[1, 10], [2, 20], [1, 20], [3, 20], [1, 30], [2, 30], [3, 30]], present)))
present(JSON.stringify(AnnotationMetrics.i._selfOrderCount(
[[2, 71], [2, 96], [3, 98], [2, 100], [5, 120], [5, 130], [5, 135], [3, 140], [5, 180]], present)))
[[2, 71, 2], [2, 96, 5], [3, 98, 3], [2, 100, 8], [5, 120, 2], [5, 130, 3], [5, 135, 4], [3, 140, 1], [5, 180, 2]], present)))
present(JSON.stringify(AnnotationMetrics.i._selfOrderCount(
[[5, 135], [2, 100], [2, 71], [2, 96], [5, 130], [3, 98], [5, 180], [5, 120], [3, 140]], present)))
present(JSON.stringify(AnnotationMetrics.i._selfOrderCount(
[[2, 71], [2, 96], [3, 98], [2, 98], [5, 98], [5, 130], [5, 135], [3, 140], [5, 180]], present)))
present(JSON.stringify(AnnotationMetrics.i._selfOrderCount(
[[2, 65], [3, 65], [2, 89], [3, 89], [4, 35], [4, 35]], present)))

present(AnnotationMetrics.i._clusteringFreeRecall(
[[2, 1], [4, 2], [4, 3], [3, 4], [2, 5], [3, 6], [1, 7], [4, 8], [4, 9]], present
Expand Down
4 changes: 2 additions & 2 deletions src/adonisjs/public/report/js/report-annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ReportManager {
let g2csv = ''
let sep = ''
for (const g of groups) {
g2csv += sep + ReportManager.catList[g[0]-1] + ':' + g[2]
g2csv += `${sep + ReportManager.catList[g[0]-1]}:${g[1]}/${g[2]}`
sep = '; '
}
return g2csv
Expand All @@ -181,7 +181,7 @@ class ReportManager {
for (const m in ReportManager.catList)
table += ',"' + ReportManager.catList[m] + '"'

table += ',"self order groups","self order ordered"\n'
table += ',"categories ordered","self order grouped"\n'

for (const c of cases.message) {
// remove prefix from title
Expand Down

0 comments on commit ebde53c

Please sign in to comment.