Skip to content
Open
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
11 changes: 11 additions & 0 deletions instutil/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
targets.ttl: The-Targets.md
./inst2ttl.pl $< > $@.tmp && owltools $@.tmp && mv $@.tmp $@
.PRECIOUS: targets.ttl

# make like this: remake targets-ann.ttl >& DEBUG
targets-ann.ttl: targets.ttl
blip-findall -debug ann -r gemet -r envo -i ../src/sdgio.obo -goal ix -i $< -consult annotate_goals.pro annotate_label/2 > $@.tmp && mv $@.tmp $@

merged.owl: targets.ttl targets-ann.ttl
owltools --catalog-xml ../src/catalog-v001.xml $^ ../src/sdgio.owl --merge-support-ontologies --merge-imports-closure -o $@

21 changes: 21 additions & 0 deletions instutil/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Experimental approach to automatically extract an OWL representation of the goals and targets.

Opened merged.owl in Protege

The model is

goal
--[has-part]-->
target
--[has-participant]--> ENVO-continuant
--[has-part]--> ENVO-process
--[MENTIONS]--> Anything else

As we keep adding to SDGIO, we will keep rerunning the pipeline, and
in theory the results should improve. We will also add heuristics to
refine the semantically useless MENTIONS assertions (there are useful
to indicate that we may be missing something in the ontology).

exclusions can be added directly to the prolog


71 changes: 71 additions & 0 deletions instutil/annotate_goals.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
:- use_module(bio(annotator)).

ok('ENVO').
ok('SDGIO').
ok('PCO').
ok('NCBITaxon').
ok('GEMET').
not_obo('SDGIO').
%not_obo('GEMET').


ix :-
format('@base <http://purl.unep.org/sdg/> .~n'),
%format('@prefix ENVO: <http://purl.obolibrary.org/obo/ENVO_> .~n'),
format('@prefix SDGIO: <http://purl.unep.org/sdg/SDGIO_> .~n'),
format('@prefix has-participant: <http://purl.obolibrary.org/obo/RO_0000057> .~n'),
format('@prefix has-part: <http://purl.obolibrary.org/obo/BFO_0000051> .~n'),
format('@prefix mentions: <http://purl.unep.org/sdg/MENTIONS> .~n'),
forall((ok(S),\+not_obo(S)),
format('@prefix ~w: <http://purl.obolibrary.org/obo/~w_> .~n',[S,S])),
format('## AUTO:~n'),
nl,
initialize_annotator.

exclude_list([
all,
sound
]).


annotate_label(C,MC) :-
rdfs_label(C,L),
exclude_list(XL),
sentence_annotate(L,Matches,[excludes([L|XL])]),
member(m([MC|_],_,_),Matches),
class(MC,MCN),
debug(ann,'Annotating: ~w ==> ~w "~w"',[L,MC,MCN]),
is_ok(MC),
cls_rel(MC,R),
format('<~w> ~w ~w .~n',[C,R,MC]),
fail.

is_ok(C) :-
id_idspace(C,S),
ok(S),
!.
is_ok(C) :-
debug(ann,'BAD: ~w',[C]),
fail.



cls_rel(C,'has-participant:') :-
subclassT(C,'BFO:0000040'),
!.
cls_rel(C,'has-part:') :-
subclassT(C,'BFO:0000015'),
!.
cls_rel(_,'mentions:') :- !.





/*

blip-findall -goal ix -i z.ttl -consult annotate_goals.pro annotate_label/3
*/



69 changes: 69 additions & 0 deletions instutil/inst2ttl.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/perl
use strict;

my $goal;
my $tgt;

header();

while(<>) {
if (m@^## Goal\s+(\d+)(.*)@) {
$goal = ":goal-$1";
my $label = trim($2);
ttl($goal, 'rdfs:label', lit($label));
ttl($goal, 'rdf:type', 'SDGIO:00000000');
}

if (m@^ \*\s+(\d+)\.(\d+)(.*)@) {
$tgt = ":target-$1-$2";
my $label = trim($3);
if ($label =~ m@^by (\d+)(.*)@i) {
my $year = ":year-$1";
$label = trim($2);
ttl($tgt, 'ends-with:', $year);
ttl($year, 'rdf:type', 'BFO:0000003');
}
ttl($tgt, 'rdfs:label', lit($label));
ttl($tgt, 'part-of:', $goal);
ttl($tgt, 'rdf:type', 'SDGIO:00000001');
}

}

exit 0;

sub trim {
my $s = shift;
$s =~ s@^[\.,\s]+@@g;
return $s;
}

sub lit {
my $s = shift;
return '"'.$s.'"';
}

sub ttl {
my ($s,$p,$o) = @_;
print "$s $p $o .\n";
}

sub header {

print <<EOM;

\@base <http://purl.unep.org/sdg/> .
\@prefix : <http://purl.unep.org/sdg/> .
\@prefix BFO: <http://purl.obolibrary.org/obo/BFO_> .
\@prefix part-of: <http://purl.obolibrary.org/obo/BFO_0000050> .
\@prefix ends-with: <http://purl.obolibrary.org/obo/RO_0002230> .
\@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
\@prefix SDGIO: <http://purl.unep.org/sdg/SDGIO_> .

:goals a owl:Ontology .

## Auto-generated

EOM

}
Loading