Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/update (annotation-metrics): self order adjust/improvement #488

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading