Skip to content

Commit

Permalink
feat (report/annotations): pruned version
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Jan 20, 2024
1 parent 7d348c9 commit e26e375
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/adonisjs/public/report/annotations/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
subscribe="case/source/get"></dcc-rest>
<dcc-button label="Export Analysis" xstyle="in" topic="report/download"></dcc-button>
<dcc-button label="Export Full Annotations" xstyle="in" topic="report/full"></dcc-button>
<dcc-button label="Export BIO Single" xstyle="in" topic="report/bio/single"></dcc-button>
<dcc-button label="Export BIO Single Composed" xstyle="in" topic="report/bio/single/composed"></dcc-button>
<dcc-button label="Export BIO Single Pruned" xstyle="in" topic="report/bio/single/pruned"></dcc-button>
<dcc-button label="Export BIO Multiple" xstyle="in" topic="report/bio/multiple"></dcc-button>
</div>

Expand Down
19 changes: 12 additions & 7 deletions src/adonisjs/public/report/js/report-annotations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class ReportManager {
start () {
MessageBus.i.subscribe('report/download', this._downloadAnalysis.bind(this))
MessageBus.i.subscribe('report/bio/single', this._downloadBIO.bind(this))
MessageBus.i.subscribe('report/bio/multiple', this._downloadBIO.bind(this))
MessageBus.i.subscribe('report/bio/#', this._downloadBIO.bind(this))
MessageBus.i.subscribe('report/full', this._downloadFull.bind(this))
this._roomId = new URL(document.location).searchParams.get('roomid')
}
Expand Down Expand Up @@ -206,15 +205,20 @@ class ReportManager {
* Export BIO
*/

async _buildBIO (caseId, annotations, multiple) {
async _buildBIO (caseId, annotations, multiple, composed) {
const tt = await this._tokenize(caseId)
let tokens = tt.tokens

// plan all annotations in a single array
let plan = []
for (const an of annotations)
for (const f of an.fragments)
plan.push([f, an.categories])
for (const an of annotations) {
let first = true
for (const f of an.fragments) {
if (composed || first)
plan.push([f, an.categories])
first = false
}
}

// order them by the last position
plan = plan.sort((a, b) =>
Expand Down Expand Up @@ -386,6 +390,7 @@ class ReportManager {

async _downloadBIO (topic, message) {
const multiple = (topic == 'report/bio/multiple')
const composed = (multiple || topic == 'report/bio/single/composed')

const tprefix = document.querySelector('#tprefix').value

Expand All @@ -397,7 +402,7 @@ class ReportManager {
for (const c of cases.message) {
const ant = await this._loadAnnotations(c.id)
const bio =
await this._buildBIO(c.id, ant.annotations, multiple)
await this._buildBIO(c.id, ant.annotations, multiple, composed)
table += JSON.stringify(bio) + '\n'
}

Expand Down

0 comments on commit e26e375

Please sign in to comment.