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

Development #468

Merged
merged 3 commits into from
Dec 22, 2023
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
47 changes: 36 additions & 11 deletions src/adonisjs/public/editor/annotate/js/metrics.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
class AnnotationMetrics {
_selfOrderCount(categoriesOrder) {
_selfOrderCount(categoriesOrder, present) {
// sort by text position (second element)
const sortedL = categoriesOrder.sort((a, b) => a[1] - b[1])

// group by category (first element)
// group = [category, position, count]
// group = [category, position of the first group element, count]
const grouped = []
for (let cat = 1; cat <= 8; cat++) {
let prev = -1
let prevG = -1
let catG = null
for (let i = 0; i < sortedL.length; i++) {
if (sortedL[i][0] === cat) {
// 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]
catG = [cat, sortedL[i][1], 1] // new category grouping
grouped.push(catG)
} else {
catG[2]++
}
prevG = i
}
// last distinct position in the sequence
if (i+1 == sortedL.length || sortedL[i+1][1] !== sortedL[i][1])
prev = i
}
Expand All @@ -42,17 +44,22 @@ class AnnotationMetrics {
subs++
sortedG[prev][2] += sortedG[i][2]
sortedG.splice(i, 1)
// if (sortedG[prev][2] >= sortedG[i][2]) {
// sortedG[prev][2] += sortedG[i][2]
// sortedG.splice(i, 1)
// } else {
// sortedG[i][2] += sortedG[prev][2]
// sortedG.splice(prev, 1)
// }
}
}
}
}

if (present != null) {
present('\n\n=== Self Order Count ===')
present('--- sorted by position')
present(sortedL)
present('--- grouped by category')
present(JSON.parse(JSON.stringify(grouped)))
present('--- group sorted by position')
present(JSON.parse(JSON.stringify(sortedG)))
present('--- final group after ordering')
present(sortedG)
}

return {
groups: groupsText,
Expand All @@ -65,7 +72,7 @@ class AnnotationMetrics {
* Category clustering calculator for free recall
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3665324/
*/
_clusteringFreeRecall (categoriesOrder) {
_clusteringFreeRecall (categoriesOrder, present) {
const n = categoriesOrder.length // number of recalled items

// sort by text position (second element)
Expand Down Expand Up @@ -110,6 +117,24 @@ class AnnotationMetrics {

const arc = (r - er) / (max - er) // adjusted ratio of clustering

if (present != null) {
present('\n\n=== Clustering Free Recall ===')
present(JSON.stringify(categoriesOrder))
present('--- n = ' + n)
present('--- sorted by position')
present(JSON.stringify(sortedL))
present('--- c = ' + c)
present('--- ni')
present(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)
}

return arc
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/adonisjs/public/editor/annotate/metrics/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<script src="../js/metrics.js"></script>
</head>
<body>
<textarea id="console" rows="50" style="width:100%" readonly></textarea>
<script type="text/javascript" src="metrics.js">
<script type="text/javascript" src="test-metrics.js">
</script>
</body>
</html>
187 changes: 0 additions & 187 deletions src/adonisjs/public/editor/annotate/metrics/metrics.js

This file was deleted.

34 changes: 34 additions & 0 deletions src/adonisjs/public/editor/annotate/metrics/test-metrics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
document.querySelector('#console').value = ''

function present (output) {
document.querySelector('#console').value += output + '\n'
}

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)))
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)))
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(AnnotationMetrics.i._clusteringFreeRecall(
[[2, 1], [4, 2], [4, 3], [3, 4], [2, 5], [3, 6], [1, 7], [4, 8], [4, 9]], present
))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[3, 1], [4, 2], [4, 3], [3, 4], [1, 5], [1, 6], [3, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [4, 13], [4, 14], [3, 15]], present
))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[2, 1], [2, 2], [3, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 8], [3, 9], [3, 10], [2, 11], [1, 12], [4, 13], [4, 14], [4, 15], [4, 16], [2, 17], [2, 18], [3, 19], [1, 20]], present
))
present(AnnotationMetrics.i._clusteringFreeRecall(
[[5, 135], [2, 100], [2, 71], [2, 96], [5, 130], [3, 98], [5, 180], [5, 120], [3, 140]], present))
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))
10 changes: 8 additions & 2 deletions src/adonisjs/public/report/annotations/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<link rel="stylesheet" href="/editor/css/editor.css">

<script src="/lib/axios-0.21.0/axios.min.js"></script>
<script src="/lib/showdown/showdown.min.js"></script>

<script src="/lib/jquery-3-4-1/jquery-3.4.1.slim.min.js"></script>
<script src="/lib/popper-1-15-0/popper.min.js"></script>
Expand Down Expand Up @@ -61,7 +62,9 @@
<script src="/dccs/base/property-dcc.js"></script>
<script src="/dccs/base/connect-dcc.js"></script>


<script src="/translator/translator.js"></script>
<script src="/translator/item-templates.js"></script>

<script src="/infra/dcc-rest-proxy.js"></script>
<script src="/infra/dcc-basic.js"></script>

Expand Down Expand Up @@ -98,7 +101,10 @@
<dcc-rest id="harena-room-cases" bind="harena-room-cases" subscribe="room/cases/get"></dcc-rest>
<dcc-rest id="harena-room-case-annotations" bind="harena-room-case-annotations"
subscribe="case/annotations/get"></dcc-rest>
<dcc-button label="Export" xstyle="in" topic="report/download"></dcc-button>
<dcc-rest id="harena-room-load-case" bind="harena-room-load-case"
subscribe="case/source/get"></dcc-rest>
<dcc-button label="Export Analysis" xstyle="in" topic="report/download"></dcc-button>
<dcc-button label="Export BILOU" xstyle="in" topic="report/bilou"></dcc-button>
</div>

</div>
Expand Down
Loading
Loading