-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #861 from europeana/feat/MET-5963-DeBias
MET-5963 Add DeBias Report
- Loading branch information
Showing
39 changed files
with
1,290 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export enum DebiasSourceField { | ||
DCTERMS_ALTERNATIVE = 'DCTERMS_ALTERNATIVE', | ||
DC_DESCRIPTION = 'DC_DESCRIPTION', | ||
DC_TITLE = 'DC_TITLE', | ||
DC_SUBJECT_LITERAL = 'DC_SUBJECT_LITERAL', | ||
DC_SUBJECT_REFERENCE = 'DC_SUBJECT_REFERENCE', | ||
DC_TYPE_LITERAL = 'DC_TYPE_LITERAL', | ||
DC_TYPE_REFERENCE = 'DC_TYPE_REFERENCE' | ||
} | ||
|
||
export enum DebiasState { | ||
READY = 'READY', | ||
ERROR = 'ERROR', | ||
PROCESSING = 'PROCESSING', | ||
COMPLETED = 'COMPLETED' | ||
} | ||
|
||
export interface DebiasInfo { | ||
'dataset-id': string; | ||
state: DebiasState; | ||
'creation-date': string; | ||
} | ||
|
||
export interface DebiasTag { | ||
start: number; | ||
end: number; | ||
length: number; | ||
uri: string; | ||
} | ||
|
||
export interface DebiasValue { | ||
language: string; | ||
literal: string; | ||
tags: Array<DebiasTag>; | ||
} | ||
|
||
export interface DebiasDetection { | ||
recordId: string; | ||
europeanaId: string; | ||
valueDetection: DebiasValue; | ||
sourceField: DebiasSourceField; | ||
} | ||
|
||
export interface DebiasReport extends DebiasInfo { | ||
detections: Array<DebiasDetection>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
projects/sandbox/src/app/_translate/format-dc-field.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DebiasSourceField } from '../_models'; | ||
|
||
@Pipe({ | ||
name: 'formatDcField', | ||
standalone: true | ||
}) | ||
export class FormatDcFieldPipe implements PipeTransform { | ||
transform(value: string): string { | ||
if (value === DebiasSourceField.DC_TITLE) { | ||
return 'dc:title'; | ||
} else if (value === DebiasSourceField.DC_DESCRIPTION) { | ||
return 'dc:description'; | ||
} else if (value === DebiasSourceField.DC_TYPE_LITERAL) { | ||
return 'dc:type literal'; | ||
} else if (value === DebiasSourceField.DC_TYPE_REFERENCE) { | ||
return 'dc:type reference'; | ||
} else if (value === DebiasSourceField.DC_SUBJECT_LITERAL) { | ||
return 'dc:subject literal'; | ||
} else if (value === DebiasSourceField.DC_SUBJECT_REFERENCE) { | ||
return 'dc:subject reference'; | ||
} else if (value === DebiasSourceField.DCTERMS_ALTERNATIVE) { | ||
return 'dc:terms alternative'; | ||
} | ||
return value; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
projects/sandbox/src/app/_translate/highlight-matches-and-link.pipe.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** HighlightMatchesAndLinkPipe | ||
/* | ||
/* a text / html highlighting and link-injecting facility | ||
*/ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DebiasTag } from '../_models'; | ||
|
||
@Pipe({ | ||
name: 'highlightMatchesAndLink', | ||
standalone: true | ||
}) | ||
export class HighlightMatchesAndLinkPipe implements PipeTransform { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
transform(value: string, args?: Array<any>): string { | ||
if (args && args.length > 0 && args[0].length > 0) { | ||
const tags = args[0] as Array<DebiasTag>; | ||
if (tags.length === 0) { | ||
return value; | ||
} | ||
const startIndexes = [0]; | ||
const endIndexes: Array<number> = []; | ||
const matches: Array<string> = []; | ||
const uris: Array<string> = []; | ||
|
||
for (let i = 0; i < tags.length; i++) { | ||
endIndexes.push(tags[i].start); // close off last | ||
startIndexes.push(tags[i].end); // start new | ||
matches.push(value.substr(tags[i].start, tags[i].length)); | ||
uris.push(tags[i].uri); | ||
} | ||
|
||
endIndexes.push(value.length); | ||
|
||
let newStr = ''; | ||
|
||
// assemble result: for each match-index pair concatenate a substring with the match | ||
startIndexes.forEach((start: number, index: number) => { | ||
newStr += value.substring(start, endIndexes[index]); | ||
if (index < matches.length) { | ||
const tagOpen = `<a href="${uris[index]}" class="term-highlight external-link-debias" target="_blank">`; | ||
const tagClose = '</a>'; | ||
newStr += `${tagOpen}${matches[index]}${tagClose}`; | ||
} | ||
}); | ||
return newStr; | ||
} | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export * from './format-dc-field.pipe'; | ||
export * from './format-harvest-url.pipe'; | ||
export * from './format-license.pipe'; | ||
export * from './format-tier-dimension.pipe'; | ||
export * from './highlight-match.pipe'; | ||
export * from './highlight-matches-and-link.pipe'; | ||
export * from './rename-status.pipe'; | ||
export * from './rename-step.pipe'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.