Skip to content

Commit

Permalink
Compute an additional IC score using only subClassOf. (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
balhoff authored Feb 8, 2024
1 parent 3192573 commit a96c858
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ libfunctors.so: functors.o
information-content.ttl: rdf.facts libfunctors.so ic.dl
souffle -l functors -c ic.dl &&\
awk -v FS='\t' -v OFS='\t' '{ print $$1, $$2, "\""$$3"\"^^<http://www.w3.org/2001/XMLSchema#decimal>", $$4}' icRDF.csv >$@.tmp &&\
awk -v FS='\t' -v OFS='\t' '{ print $$1, $$2, "\""$$3"\"^^<http://www.w3.org/2001/XMLSchema#decimal>", $$4}' subClassOfICRDF.csv >>$@.tmp &&\
cat scRDF.csv >>$@.tmp && mv $@.tmp $@

antonyms_HP.txt:
Expand Down
11 changes: 11 additions & 0 deletions ic.dl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define RDFS_SUBCLASS_OF "<http://www.w3.org/2000/01/rdf-schema#subClassOf>"
#define REFERENCE_COUNT "<http://reasoner.renci.org/vocab/referenceCount>"
#define HAS_NORMALIZED_IC "<http://reasoner.renci.org/vocab/normalizedInformationContent>"
#define HAS_NORMALIZED_SUBCLASS_IC "<http://reasoner.renci.org/vocab/normalizedSubClassInformationContent>"

.functor logn(x: float): float

Expand All @@ -15,21 +17,30 @@

references(sub, super) :- rdf(sub, _, super).

subClassOf(sub, super) :- rdf(sub, RDFS_SUBCLASS_OF, super).

term(t) :- references(t, _).

totalTerms(c) :- c = count : { term(_) }.

referenceCount(t, c) :- term(t), c = count : { references(_, t) }.

subClassOfReferenceCount(t, c) :- term(t), c = count : { subClassOf(_, t) }.

maxIC(-@logn(1.0/to_float(n))) :- totalTerms(n).

normalizedIC(t, (-@logn(to_float(c)/to_float(total)))*scale) :- referenceCount(t, c), totalTerms(total), maxIC(maxic), scale=100.0/maxic.

normalizedSubClassOfIC(t, (-@logn(to_float(c)/to_float(total)))*scale) :- subClassOfReferenceCount(t, c), totalTerms(total), maxIC(maxic), scale=100.0/maxic.

icRDF(term, HAS_NORMALIZED_IC, ic, ".") :- normalizedIC(term, ic).

subClassOfICRDF(term, HAS_NORMALIZED_SUBCLASSOF_IC, ic, ".") :- normalizedSubClassOfIC(term, ic).

scRDF(term, REFERENCE_COUNT, c, ".") :- referenceCount(term, c).

// sed 's/ /\t/' <ontology.nt | sed 's/ /\t/' | sed 's/ \.$//' >rdf.facts
.input rdf
.output icRDF
.output subClassOfICRDF
.output scRDF

0 comments on commit a96c858

Please sign in to comment.