Skip to content

Commit

Permalink
Merge pull request #469 from harena-lab/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
santanche authored Jan 4, 2024
2 parents 4e1abc0 + c31d6cc commit 183fe49
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/adonisjs/public/editor/annotate/js/annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ class Annotator {
for (const r of a.fragments)
ranges.push({fragment: r, annot: [a]})
}
ranges.sort((a, b) => a.fragment.start - b.fragment.start)
ranges.sort((a, b) =>
(a.fragment.start == b.fragment.start)
? b.fragment.size - a.fragment.size // bigger first
: a.fragment.start - b.fragment.start
)
for (let r = 0; r < ranges.length - 1; r++) {
if ((ranges[r].fragment.start == ranges[r + 1].fragment.start) &&
(ranges[r].fragment.size == ranges[r + 1].fragment.size)) {
Expand Down Expand Up @@ -540,7 +544,8 @@ class Annotator {
}
const ctcategories = Object.keys(catIndex).length

const clustering = Math.round(AnnotationMetrics.i._clusteringFreeRecall(catOrder)*100) / 100
const cfr = AnnotationMetrics.i._clusteringFreeRecall(catOrder)
const clustering = (isNaN) ? cfr : Math.round(cfr * 100) / 100

if (isAnnotations) {
document.querySelector('#memory-scores').innerHTML =
Expand Down
27 changes: 23 additions & 4 deletions src/adonisjs/public/editor/annotate/js/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class AnnotationMetrics {
else
nc[cat]++
let nextPos = i + 1
while (nextPos < sortedL.length && sortedL[nextPos][1] === sortedL[i][1])
// find next position of the same category or neighbor start
while (nextPos < sortedL.length &&
sortedL[nextPos][0] != cat && sortedL[nextPos][1] === sortedL[i][1])
nextPos++
if (nextPos < sortedL.length) {
let sp = nextPos
Expand Down Expand Up @@ -115,7 +117,24 @@ class AnnotationMetrics {

const ds = r - er // deviation score

const arc = (r - er) / (max - er) // adjusted ratio of clustering
const arc =
(max - er == 0) ? '0/0' : (r - er) / (max - er) // adjusted ratio of clustering

console.log('\n\n=== Clustering Free Recall ===')
console.log(JSON.stringify(categoriesOrder))
console.log('--- n = ' + n)
console.log('--- sorted by position')
console.log(JSON.stringify(sortedL))
console.log('--- c = ' + c)
console.log('--- ni')
console.log(JSON.stringify(nc))
console.log('--- r = ' + r)
console.log('--- max = ' + max)
console.log('--- E(r) = ' + Math.round(er * 100) / 100)
console.log('--- RR = ' + Math.round(rr * 100) / 100)
console.log('--- MRR = ' + Math.round(mrr * 100) / 100)
console.log('--- DS = ' + Math.round(ds * 100) / 100)
console.log('--- ARC = ' + ((isNaN(arc)) ? arc : Math.round(arc * 100) / 100))

if (present != null) {
present('\n\n=== Clustering Free Recall ===')
Expand All @@ -125,14 +144,14 @@ class AnnotationMetrics {
present(JSON.stringify(sortedL))
present('--- c = ' + c)
present('--- ni')
present(nc)
present(JSON.stringify(nc))
present('--- r = ' + r)
present('--- max = ' + max)
present('--- E(r) = ' + Math.round(er * 100) / 100)
present('--- RR = ' + Math.round(rr * 100) / 100)
present('--- MRR = ' + Math.round(mrr * 100) / 100)
present('--- DS = ' + Math.round(ds * 100) / 100)
present('--- ARC = ' + Math.round(arc * 100) / 100)
present('--- ARC = ' + ((isNaN(arc)) ? arc : Math.round(arc * 100) / 100))
}

return arc
Expand Down
17 changes: 16 additions & 1 deletion src/adonisjs/public/editor/annotate/metrics/test-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ present(AnnotationMetrics.i._clusteringFreeRecall(
present(AnnotationMetrics.i._clusteringFreeRecall(
[[2, 71], [2, 96], [3, 98], [2, 98], [5, 98], [5, 130], [5, 135], [3, 140], [5, 180]], present))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[2, 71], [2, 96], [3, 98], [2, 98], [5, 98], [7,98], [5, 130], [5, 135], [3, 140], [5, 180]], present))
[[2, 71], [2, 96], [3, 98], [2, 98], [5, 98], [7,98], [5, 130], [5, 135], [3, 140], [5, 180]], present))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[2, 1], [5, 2], [2, 3], [3, 4], [1, 5], [5, 6]], present
))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[1, 1], [1, 2], [1, 3], [2, 4]], present
))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[7,1],[3,2],[7,3],[3,4],[2,5],[2,6]], present
))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[1,1],[1,2],[5,3],[2,4],[8,5],[1,6],[1,7]], present
))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[5,1], [5,2], [5,3]], present
))

0 comments on commit 183fe49

Please sign in to comment.