
rationals.transformations.ToDFA Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of HermiT Show documentation
Show all versions of HermiT Show documentation
HermiT is reasoner for ontologies written using the Web
Ontology Language (OWL). Given an OWL file, HermiT can determine whether or
not the ontology is consistent, identify subsumption relationships between
classes, and much more.
This is the maven build of HermiT and is designed for people who wish to use
HermiT from within the OWL API. It is not officially supported by the HermiT
development team, but was built initially for use with the Clojure-OWL
library. It is built using the HermiT source tree without modification.
There have been some additions to the test source tree to account for
differences between the maven and ant environment; these are small and
(hopefully) maintainable.
The version number of this package is a composite of the HermiT version and
an value representing releases of this packaged version. So, 1.3.7.1 is the
first release of the mavenized version of HermiT based on the 1.3.7 release
of HermiT.
This package includes the Jautomata library
(http://jautomata.sourceforge.net/), and builds with it directly. This
library appears to be no longer under active development, and so a "fork"
seems appropriate. No development is intended or anticipated on this code
base.
The newest version!
package rationals.transformations;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import rationals.Automaton;
import rationals.NoSuchStateException;
import rationals.State;
import rationals.Transition;
/**
* Determinization of an automaton.
*
* @author yroos
* @version $Id: ToDFA.java 7 2006-08-31 23:01:30Z oqube $
*/
public class ToDFA implements UnaryTransformation {
public Automaton transform(Automaton a) {
Automaton ret = new Automaton();
Map bmap = new HashMap();
List /* < Set > */todo = new ArrayList();
Set /* < Set > */done = new HashSet();
Set as = TransformationsToolBox.epsilonClosure(a.initials(), a);
State from = ret.addState(true, TransformationsToolBox
.containsATerminalState(as));
bmap.put(as, from);
todo.add(as);
do {
Set sts = (Set) todo.remove(0);
from = (State) bmap.get(sts);
if (done.contains(sts))
continue;
done.add(sts);
/* get transition sets */
Map tam = TransformationsToolBox.mapAlphabet(a.delta(sts), a);
/* unsynchronizable transitions in A */
for (Iterator i = tam.entrySet().iterator(); i.hasNext();) {
Map.Entry me = (Map.Entry) i.next();
Object l = me.getKey();
as = (Set) me.getValue();
Set asc = TransformationsToolBox.epsilonClosure(as, a);
State to = (State) bmap.get(asc);
if (to == null) {
to = ret.addState(false, TransformationsToolBox
.containsATerminalState(asc));
bmap.put(asc, to);
}
todo.add(asc);
try {
ret.addTransition(new Transition(from, l, to));
} catch (NoSuchStateException e) {
assert false;
}
}
} while (!todo.isEmpty());
return ret;
}
/*
public Automaton transform(Automaton a) {
a = new EpsilonTransitionRemover().transform(a);
Automaton b = new Automaton();
Map map = new HashMap();
LinkedList l = new LinkedList();
Set done = new HashSet();
Set e = a.initials();
boolean t = TransformationsToolBox.containsATerminalState(e);
map.put(e, b.addState(true, t));
l.add(e);
while (!l.isEmpty()) {
Set e1 = (Set) l.removeFirst();
done.add(e1);
State ep1 = (State) map.get(e1);
Iterator j = a.alphabet().iterator();
Object label = null;
while (j.hasNext()) {
label = j.next();
Iterator i = e1.iterator();
Set e2 = a.getStateFactory().stateSet();
while (i.hasNext()) {
Iterator k = a.delta((State) i.next(), label).iterator();
while (k.hasNext()) {
e2.add(((Transition) k.next()).end());
}
}
State ep2;
if (!e2.isEmpty()) {
if (!map.containsKey(e2)) {
t = TransformationsToolBox.containsATerminalState(e2);
map.put(e2, b.addState(false, t));
}
ep2 = (State) map.get(e2);
try {
b.addTransition(new Transition(ep1, label, ep2));
} catch (NoSuchStateException x) {
}
if (!done.contains(e2))
l.add(e2);
}
}
}
return b;
}
*/
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy