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
643b9478
Commit
643b9478
authored
15 years ago
by
Jérôme Euzenat
Browse files
Options
Downloads
Patches
Plain Diff
- Moved to Properties instead of Parameters
parent
1fd4d726
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
html/tutorial/tutorial3/NewMatcher.java
+49
-60
49 additions, 60 deletions
html/tutorial/tutorial3/NewMatcher.java
with
49 additions
and
60 deletions
html/tutorial/tutorial3/NewMatcher.java
+
49
−
60
View file @
643b9478
/*
/*
* $Id
: Skeleton.java 1106 2010-01-20 11:00 euzenat
$
* $Id$
*
*
* Copyright (C) 2006-2010, INRIA
Rhône-Alpes
* Copyright (C) 2006-2010, INRIA
*
*
* Modifications to the initial code base are copyright of their
* Modifications to the initial code base are copyright of their
* respective authors, or their employers as appropriate. Authorship
* respective authors, or their employers as appropriate. Authorship
...
@@ -27,13 +27,13 @@
...
@@ -27,13 +27,13 @@
// Alignment API classes
// Alignment API classes
import
org.semanticweb.owl.align.Alignment
;
import
org.semanticweb.owl.align.Alignment
;
import
org.semanticweb.owl.align.AlignmentProcess
;
import
org.semanticweb.owl.align.AlignmentProcess
;
import
org.semanticweb.owl.align.Parameters
;
import
org.semanticweb.owl.align.AlignmentException
;
import
org.semanticweb.owl.align.AlignmentException
;
// Alignment API implementation classes
// Alignment API implementation classes
import
fr.inrialpes.exmo.align.impl.ObjectAlignment
;
import
fr.inrialpes.exmo.align.impl.ObjectAlignment
;
import
java.net.URI
;
import
java.net.URI
;
import
java.util.Properties
;
/**
/**
* The Skeleton of code for extending the alignment API
* The Skeleton of code for extending the alignment API
...
@@ -42,63 +42,52 @@ import java.net.URI;
...
@@ -42,63 +42,52 @@ import java.net.URI;
public
class
NewMatcher
extends
ObjectAlignment
implements
AlignmentProcess
{
public
class
NewMatcher
extends
ObjectAlignment
implements
AlignmentProcess
{
public
NewMatcher
()
{
public
NewMatcher
()
{
}
}
/* The only method to implement is align.
/**
All the resources for reading the ontologies and rendering the alignment are from ObjectAlignment and its superclasses:
* The only method to implement is align.
* All the resources for reading the ontologies and rendering the alignment are from ObjectAlignment and its superclasses:
* - ontology1() and ontology2() returns objects LoadedOntology
* - addAlignCell adds a new mapping in the alignment object
*/
public
void
align
(
Alignment
alignment
,
Properties
param
)
throws
AlignmentException
{
try
{
// Match classes
for
(
Object
cl2:
ontology2
().
getClasses
()
){
for
(
Object
cl1:
ontology1
().
getClasses
()
){
// add mapping into alignment object
addAlignCell
(
cl1
,
cl2
,
"="
,
match
(
cl1
,
cl2
));
}
}
// Match dataProperties
for
(
Object
p2:
ontology2
().
getDataProperties
()
){
for
(
Object
p1:
ontology1
().
getDataProperties
()
){
// add mapping into alignment object
addAlignCell
(
p1
,
p2
,
"="
,
match
(
p1
,
p2
));
}
}
// Match objectProperties
for
(
Object
p2:
ontology2
().
getObjectProperties
()
){
for
(
Object
p1:
ontology1
().
getObjectProperties
()
){
// add mapping into alignment object
addAlignCell
(
p1
,
p2
,
"="
,
match
(
p1
,
p2
));
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
- ontology1() and ontology2() returns objects LoadedOntology
/*
- addAlignCell adds a new mapping in the alignment object
* *Very* simple matcher, based on equality of names (in the example, only classes and properties)
*/
*/
public
double
match
(
Object
o1
,
Object
o2
)
throws
AlignmentException
{
String
s1
=
ontology1
().
getEntityName
(
o1
);
public
void
align
(
Alignment
alignment
,
Parameters
param
)
throws
AlignmentException
{
String
s2
=
ontology2
().
getEntityName
(
o2
);
if
(
s1
==
null
||
s2
==
null
)
return
0
.;
try
{
if
(
s1
.
toLowerCase
().
equals
(
s2
.
toLowerCase
()))
{
// Match classes
return
1.0
;
for
(
Object
cl2:
ontology2
().
getClasses
()
){
}
else
{
for
(
Object
cl1:
ontology1
().
getClasses
()
){
return
0
.;
// add mapping into alignment object
}
addAlignCell
(
cl1
,
cl2
,
"="
,
match
(
cl1
,
cl2
));
}
}
}
// Match dataProperties
for
(
Object
p2:
ontology2
().
getDataProperties
()
){
for
(
Object
p1:
ontology1
().
getDataProperties
()
){
// add mapping into alignment object
addAlignCell
(
p1
,
p2
,
"="
,
match
(
p1
,
p2
));
}
}
// Match objectProperties
for
(
Object
p2:
ontology2
().
getObjectProperties
()
){
for
(
Object
p1:
ontology1
().
getObjectProperties
()
){
// add mapping into alignment object
addAlignCell
(
p1
,
p2
,
"="
,
match
(
p1
,
p2
));
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/*
*Very* simple matcher, based on equality of names (in the example, only classes and properties)
*/
public
double
match
(
Object
o1
,
Object
o2
)
throws
AlignmentException
{
String
s1
=
ontology1
().
getEntityName
(
o1
);
String
s2
=
ontology2
().
getEntityName
(
o2
);
if
(
s1
==
null
||
s2
==
null
)
return
0
.;
if
(
s1
.
toLowerCase
().
equals
(
s2
.
toLowerCase
()))
{
return
1.0
;
}
else
{
return
0
.;
}
}
}
}
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