Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alignment API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
moex
Alignment API
Commits
0bc78d93
Commit
0bc78d93
authored
20 years ago
by
David Loup
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
984c514a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java
+113
-98
113 additions, 98 deletions
src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java
with
113 additions
and
98 deletions
src/fr/inrialpes/exmo/align/impl/eval/PRecEvaluator.java
+
113
−
98
View file @
0bc78d93
...
...
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
fr.inrialpes.exmo.align.impl
;
package
fr.inrialpes.exmo.align.impl
;
import
org.semanticweb.owl.align.Alignment
;
import
org.semanticweb.owl.align.AlignmentException
;
...
...
@@ -50,105 +50,120 @@ import org.xml.sax.SAXException;
*/
public
class
PRecEvaluator
extends
BasicEvaluator
{
private
double
precision
=
0
.;
private
double
recall
=
0
.;
private
double
fallout
=
0
.;
private
double
overall
=
0
.;
private
double
fmeasure
=
0
.;
/** Creation **/
public
PRecEvaluator
(
Alignment
align1
,
Alignment
align2
){
super
(
align1
,
align2
);
}
// Presision: nbfound - nbexpected / nbexpected
// Recall: nbfound / nbexpected
// ----
// Signal:
// Noise:
public
double
eval
(
Parameters
params
)
throws
AlignmentException
{
int
nbexpected
=
align1
.
nbCells
();
int
nbfound
=
align2
.
nbCells
();
int
nbcorrect
=
0
;
// nb of cells correctly identified
precision
=
0
.;
recall
=
0
.;
for
(
Enumeration
e
=
align1
.
getElements
()
;
e
.
hasMoreElements
()
;)
{
Cell
c1
=
(
Cell
)
e
.
nextElement
();
Cell
c2
=
(
Cell
)
align2
.
getAlignCell1
((
OWLEntity
)
c1
.
getObject1
());
if
(
c2
!=
null
){
if
(
c1
.
getObject2
()
==
c2
.
getObject2
()
)
{
nbcorrect
++;
private
double
precision
=
0
.;
private
double
recall
=
0
.;
private
double
fallout
=
0
.;
private
double
overall
=
0
.;
private
double
fmeasure
=
0
.;
/** Creation **/
public
PRecEvaluator
(
Alignment
align1
,
Alignment
align2
)
{
super
(
align1
,
align2
);
}
// Presision: nbfound - nbexpected / nbexpected
// Recall: nbfound / nbexpected
// ----
// Signal:
// Noise:
public
double
eval
(
Parameters
params
)
throws
AlignmentException
{
int
nbexpected
=
align1
.
nbCells
();
int
nbfound
=
align2
.
nbCells
();
int
nbcorrect
=
0
;
// nb of cells correctly identified
precision
=
0
.;
recall
=
0
.;
for
(
Enumeration
e
=
align1
.
getElements
();
e
.
hasMoreElements
();)
{
Cell
c1
=
(
Cell
)
e
.
nextElement
();
try
{
Cell
c2
=
(
Cell
)
align2
.
getAlignCell1
((
OWLEntity
)
c1
.
getObject1
());
if
(
c2
!=
null
)
{
URI
uri1
=
((
OWLEntity
)
c1
.
getObject2
()).
getURI
();
URI
uri2
=
((
OWLEntity
)
c2
.
getObject2
()).
getURI
();
// if (c1.getobject2 == c2.getobject2)
if
(
uri1
.
toString
().
equals
(
uri2
.
toString
()))
{
nbcorrect
++;
}
}
}
catch
(
Exception
exc
)
{
}
}
}
// What is the definition if:
// nbfound is 0 (p, r are 0)
// nbexpected is 0 [=> nbcorrect is 0] (r=100, p=0[if nbfound>0, 100 otherwise])
// precision+recall is 0 [= nbcorrect is 0]
// precision is 0 [= nbcorrect is 0]
precision
=
(
double
)
nbcorrect
/
(
double
)
nbfound
;
recall
=
(
double
)
nbcorrect
/
(
double
)
nbexpected
;
fallout
=
(
double
)
(
nbfound
-
nbcorrect
)
/
(
double
)
nbfound
;
fmeasure
=
2
*
precision
*
recall
/
(
precision
+
recall
);
overall
=
recall
*
(
2
-
(
1
/
precision
));
result
=
recall
/
precision
;
//System.err.println(">>>> " + nbcorrect + " : " + nbfound + " : " + nbexpected);
return
(
result
);
}
// What is the definition if:
// nbfound is 0 (p, r are 0)
// nbexpected is 0 [=> nbcorrect is 0] (r=100, p=0[if nbfound>0, 100 otherwise])
// precision+recall is 0 [= nbcorrect is 0]
// precision is 0 [= nbcorrect is 0]
precision
=
(
double
)
nbcorrect
/
(
double
)
nbfound
;
recall
=
(
double
)
nbcorrect
/
(
double
)
nbexpected
;
fallout
=
(
double
)(
nbfound
-
nbcorrect
)
/
(
double
)
nbfound
;
fmeasure
=
2
*
precision
*
recall
/
(
precision
+
recall
);
overall
=
recall
*(
2
-(
1
/
precision
));
result
=
recall
/
precision
;
//System.err.println(">>>> "+nbcorrect+" : "+nbfound+" : "+nbexpected);
return
(
result
);
}
/**
* This now output the Lockheed format. However, the lookheed format
* was intended to compare two merged ontologies instead of two alignment.
* So it refered to the:
* - input ontology A
* - input ontology B
* - alignement algorithm (used for obtaining what ????).
* While we compare two alignments (so the source and the reference to these
* algorithms should be within the alignment structure.
*/
public
void
write
(
PrintStream
writer
)
throws
java
.
io
.
IOException
{
writer
.
println
(
"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"
);
writer
.
println
(
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'\n xmlns:map='http://www.atl.external.lmco.com/projects/ontology/ResultsOntology.n3#'>"
);
writer
.
println
(
" <map:output rdf:about=''>"
);
// Missing items:
// writer.println(" <map:algorithm rdf:resource=\"\">");
// writer.println(" <map:intutA rdf:resource=\"\">");
// writer.println(" <map:inputB rdf:resource=\"\">");
// Other missing items (easy to get)
// writer.println(" <map:falseNegative>");
// writer.println(" <map:falsePositive>");
writer
.
print
(
" <map:precision>"
);
writer
.
print
(
precision
);
writer
.
print
(
"</map:precision>\n <map:recall>"
);
writer
.
print
(
recall
);
writer
.
print
(
"</map:recall>\n <fallout>"
);
writer
.
print
(
fallout
);
writer
.
print
(
"</fallout>\n <map:fMeasure>"
);
writer
.
print
(
fmeasure
);
writer
.
print
(
"</map:fMeasure>\n <map:oMeasure>"
);
writer
.
print
(
overall
);
writer
.
print
(
"</map:oMeasure>\n <result>"
);
writer
.
print
(
result
);
writer
.
print
(
"</result>\n </map:output>\n</rdf:RDF>\n"
);
}
/* public void write( PrintStream writer ) throws java.io.IOException {
writer.print("<rdf:RDF>\n <Evaluation class=\"PRecEvaluator\">\n <precision>");
writer.print(precision);
writer.print("</precision>\n <recall>");
writer.print(recall);
writer.print("</recall>\n <fallout>");
writer.print(fallout);
writer.print("</fallout>\n <fmeasure>");
writer.print(fmeasure);
writer.print("</fmeasure>\n <overall>");
writer.print(overall);
writer.print("</overall>\n <result>");
writer.print(result);
writer.print("</result>\n </Evaluation>\n</rdf:RDF>\n");
}*/
}
/**
* This now output the Lockheed format. However, the lookheed format
* was intended to compare two merged ontologies instead of two alignment.
* So it refered to the:
* - input ontology A
* - input ontology B
* - alignement algorithm (used for obtaining what ????).
* While we compare two alignments (so the source and the reference to these
* algorithms should be within the alignment structure.
*/
public
void
write
(
PrintStream
writer
)
throws
java
.
io
.
IOException
{
writer
.
println
(
"<?xml version='1.0' encoding='utf-8' standalone='yes'?>"
);
writer
.
println
(
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'\n xmlns:map='http://www.atl.external.lmco.com/projects/ontology/ResultsOntology.n3#'>"
);
writer
.
println
(
" <map:output rdf:about=''>"
);
// Missing items:
// writer.println(" <map:algorithm rdf:resource=\"\">");
// writer.println(" <map:intutA rdf:resource=\"\">");
// writer.println(" <map:inputB rdf:resource=\"\">");
// Other missing items (easy to get)
// writer.println(" <map:falseNegative>");
// writer.println(" <map:falsePositive>");
writer
.
print
(
" <map:precision>"
);
writer
.
print
(
precision
);
writer
.
print
(
"</map:precision>\n <map:recall>"
);
writer
.
print
(
recall
);
writer
.
print
(
"</map:recall>\n <fallout>"
);
writer
.
print
(
fallout
);
writer
.
print
(
"</fallout>\n <map:fMeasure>"
);
writer
.
print
(
fmeasure
);
writer
.
print
(
"</map:fMeasure>\n <map:oMeasure>"
);
writer
.
print
(
overall
);
writer
.
print
(
"</map:oMeasure>\n <result>"
);
writer
.
print
(
result
);
writer
.
print
(
"</result>\n </map:output>\n</rdf:RDF>\n"
);
}
/* public void write( PrintStream writer ) throws java.io.IOException {
writer.print("<rdf:RDF>\n <Evaluation class=\"PRecEvaluator\">\n <precision>");
writer.print(precision);
writer.print("</precision>\n <recall>");
writer.print(recall);
writer.print("</recall>\n <fallout>");
writer.print(fallout);
writer.print("</fallout>\n <fmeasure>");
writer.print(fmeasure);
writer.print("</fmeasure>\n <overall>");
writer.print(overall);
writer.print("</overall>\n <result>");
writer.print(result);
writer.print("</result>\n </Evaluation>\n</rdf:RDF>\n");
}*/
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment