Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
INB
eTRANSAFE
pretox-rest-api
Commits
1d03e12e
Commit
1d03e12e
authored
Nov 10, 2021
by
jcorvi
Browse files
Merge branch 'allevidence_2' into 'allevidence'
new version ready for presentation See merge request
!13
parents
fed1eea3
fef9e358
Pipeline
#25794
passed with stage
in 3 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/es/bsc/inb/ades/rest/api/controllers/DocumentController.java
View file @
1d03e12e
...
...
@@ -94,15 +94,22 @@ public class DocumentController {
return
snippet
;
}
@RequestMapping
(
"/documents/{id}/evidence/findings"
)
public
String
findAllFindingEvidence
(
@PathVariable
(
value
=
"id"
)
Long
id
)
{
String
snippet
=
documentService
.
findFindingsEvidenceByDocumentId
(
id
);
return
snippet
;
}
@RequestMapping
(
"/documents/{id}/evidence/all"
)
public
String
findAllEvidence
(
@PathVariable
(
value
=
"id"
)
Long
id
)
{
String
snippet
=
documentService
.
find
Findings
EvidenceByDocumentId
(
id
);
String
snippet
=
documentService
.
find
All
EvidenceByDocumentId
(
id
);
return
snippet
;
}
@RequestMapping
(
"/documents/{id}/evidence/sentences"
)
public
String
findSentencesEvidence
(
@PathVariable
(
value
=
"id"
)
Long
id
)
{
String
snippet
=
documentService
.
findSentencesEvidenceByDocumentId
(
id
);
//String snippet = documentService.findAllEvidenceByDocumentId(id);
return
snippet
;
}
...
...
src/main/java/es/bsc/inb/ades/rest/api/model/SRDomainFinding.java
View file @
1d03e12e
package
es.bsc.inb.ades.rest.api.model
;
import
org.apache.tomcat.util.bcel.classfile.Constant
;
import
es.bsc.inb.ades.rest.api.util.Constants
;
/**
* This class describes a finding in SR-Domain format.
* No textual evidence.
...
...
@@ -57,7 +61,14 @@ public class SRDomainFinding implements Cloneable{
}
public
String
getSrdomain_value
()
{
return
SRDOMAIN_DESC
+
"("
+
SRDOMAIN
+
")"
;
if
(
Constants
.
SEND_DOMAIN_NAMES
.
get
(
SRDOMAIN
)!=
null
)
{
return
Constants
.
SEND_DOMAIN_NAMES
.
get
(
SRDOMAIN
)
+
"("
+
SRDOMAIN
+
")"
;
}
else
if
(
SRDOMAIN
==
null
||
SRDOMAIN
.
equals
(
""
))
{
return
""
;
}
else
{
return
SRDOMAIN
;
}
}
public
String
getSrfndg_value
()
{
...
...
src/main/java/es/bsc/inb/ades/rest/api/services/DocumentService.java
View file @
1d03e12e
...
...
@@ -30,6 +30,8 @@ public interface DocumentService {
String
findFindingsEvidenceByDocumentId
(
Long
id
);
String
findAllEvidenceByDocumentId
(
Long
id
);
String
findSentencesEvidenceByDocumentId
(
Long
id
);
String
findTextByDocumentId
(
Long
id
);
...
...
src/main/java/es/bsc/inb/ades/rest/api/services/DocumentServiceImpl.java
View file @
1d03e12e
...
...
@@ -215,10 +215,20 @@ public class DocumentServiceImpl implements DocumentService {
* Get Findings evidence from a document
*/
public
String
findFindingsEvidenceByDocumentId
(
Long
id
)
{
DocumentAnnotations
documentAnnotations
=
this
.
findDocumentAnnotationsByDocumentId
(
id
);
Document
document
=
this
.
findByDocumentId
(
id
);
return
this
.
generateAllFindingsEvidenceSnippet
(
document
.
getText
(),
documentAnnotations
.
getRelevantSentences
());
}
/**
* Get Findings evidence from a document
*/
public
String
findAllEvidenceByDocumentId
(
Long
id
)
{
DocumentAnnotations
documentAnnotations
=
this
.
findDocumentAnnotationsByDocumentId
(
id
);
Document
document
=
this
.
findByDocumentId
(
id
);
return
this
.
generateAllEvidenceSnippet
(
document
.
getText
(),
documentAnnotations
.
getRelevantSentences
());
}
/**
* Get relevant sentences evidence from a document
*/
...
...
@@ -636,6 +646,98 @@ public class DocumentServiceImpl implements DocumentService {
int
a
=
1
;
int
r
=
1
;
for
(
Annotation
sentenceAnnotation
:
sentences
)
{
JsonArray
values_sentence
=
new
JsonArray
();
//values_sentence.add("T"+t);
values_sentence
.
add
(
"S"
+
sentenceAnnotation
.
getId
());
values_sentence
.
add
(
"RELEVANT_SENTENCE"
);
JsonArray
offste_sentence
=
new
JsonArray
();
JsonArray
offste2_sentence
=
new
JsonArray
();
offste_sentence
.
add
(
sentenceAnnotation
.
getStartOffset
());
offste_sentence
.
add
(
sentenceAnnotation
.
getEndOffset
());
offste2_sentence
.
add
(
offste_sentence
);
values_sentence
.
add
(
offste2_sentence
);
entities
.
add
(
values_sentence
);
t
++;
if
(
sentenceAnnotation
.
getFindings
()!=
null
)
{
for
(
Finding
findingSelected
:
sentenceAnnotation
.
getFindings
())
{
List
<
Annotation
>
all
=
findingSelected
.
generateSortedAnnotationsAll
();
String
id_finding
=
""
;
for
(
Annotation
annotation
:
all
)
{
JsonArray
values
=
new
JsonArray
();
String
type
=
annotation
.
getFeature
(
"ANNOTATION_TYPE"
);
//String id = "T"+t;
String
id
=
"E"
+
annotation
.
getId
();
//TODO source
// String source = annotation.getFeature("SOURCES");
// if(source!=null && !source.equals("")) {
// id = id + " - SOURCE: " + source;
// }
// values.add("T"+t+ " - SOURCE: " + source);
values
.
add
(
id
);
values
.
add
(
type
);
JsonArray
offste
=
new
JsonArray
();
JsonArray
offste2
=
new
JsonArray
();
offste
.
add
(
annotation
.
getStartOffset
());
offste
.
add
(
annotation
.
getEndOffset
());
offste2
.
add
(
offste
);
values
.
add
(
offste2
);
entities
.
add
(
values
);
if
(
type
.
equals
(
"FINDING"
)
||
type
.
equals
(
"STUDY_TESTCD"
)
)
{
id_finding
=
"T"
+
t
;
JsonArray
values_a
=
new
JsonArray
();
values_a
.
add
(
"A"
+
a
);
values_a
.
add
(
"Notorious"
);
values_a
.
add
(
id_finding
);
attributes
.
add
(
values_a
);
a
++;
}
else
{
JsonArray
values_r
=
new
JsonArray
();
values_r
.
add
(
"R"
+
r
);
values_r
.
add
(
"Relation"
);
JsonArray
values_r_e
=
new
JsonArray
();
JsonArray
values_r_e_v
=
new
JsonArray
();
values_r_e_v
.
add
(
"Entity"
);
values_r_e_v
.
add
(
id_finding
);
values_r_e
.
add
(
values_r_e_v
);
JsonArray
values_r_e_v_2
=
new
JsonArray
();
values_r_e_v_2
.
add
(
"Subentity"
);
values_r_e_v_2
.
add
(
"T"
+
t
);
values_r_e
.
add
(
values_r_e_v_2
);
values_r
.
add
(
values_r_e
);
relations
.
add
(
values_r
);
r
++;
}
t
++;
}
}
}
}
findings_evidence
.
add
(
"entities"
,
entities
);
findings_evidence
.
add
(
"attributes"
,
attributes
);
findings_evidence
.
add
(
"relations"
,
relations
);
return
gsonBuilder
.
toJson
(
findings_evidence
).
toString
();
}
/**
* Generate the evidence of view all button.
* @param text
* @param findingSelected
* @return
*/
private
String
generateAllFindingsEvidenceSnippet
(
String
text
,
List
<
Annotation
>
sentences
)
{
Gson
gsonBuilder
=
new
GsonBuilder
().
create
();
JsonObject
findings_evidence
=
new
JsonObject
();
findings_evidence
.
addProperty
(
"text"
,
text
);
JsonArray
entities
=
new
JsonArray
();
JsonArray
attributes
=
new
JsonArray
();
JsonArray
relations
=
new
JsonArray
();
int
t
=
1
;
int
a
=
1
;
int
r
=
1
;
for
(
Annotation
sentenceAnnotation
:
sentences
)
{
// JsonArray values_sentence = new JsonArray();
// values_sentence.add("T"+t);
// values_sentence.add("PRETOX_RELEVANT_SENTENCE");
...
...
src/main/java/es/bsc/inb/ades/rest/api/util/Constants.java
View file @
1d03e12e
package
es.bsc.inb.ades.rest.api.util
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Constants
{
public
static
int
SLICE_START
=
1000
;
...
...
@@ -7,4 +10,26 @@ public class Constants {
public
static
int
POINTS_INT
=
5
;
public
static
String
POINTS
=
"....."
;
public
static
Map
<
String
,
String
>
SEND_DOMAIN_NAMES
=
new
HashMap
<
String
,
String
>(){{
put
(
"LB"
,
"Laboratory Test Results"
);
put
(
"BW"
,
"Body Weight"
);
put
(
"BG"
,
"Body Weight Gain"
);
put
(
"CV"
,
"Cardiovascular Domain"
);
put
(
"CL"
,
"Clinical"
);
put
(
"DD"
,
"Death Diagnosis"
);
put
(
"EG"
,
"ECG Test Results"
);
put
(
"FM"
,
"Fetal Measurements"
);
put
(
"FW"
,
"Food And Water"
);
put
(
"FX"
,
"Fetal Pathology Findings"
);
put
(
"MA"
,
"Macroscopic Findings"
);
put
(
"MI"
,
"Microscopic Findings"
);
put
(
"OM"
,
"Organ Measurements"
);
put
(
"RE"
,
"Respiratory Findings"
);
put
(
"TF"
,
"Tumor Findings"
);
put
(
"VS"
,
"Vital Signs"
);
}};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment