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

feat (report/annotations): pruned version #477

Merged
merged 1 commit into from
Jan 20, 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
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
Loading