All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rationals.transformations.Accessible Maven / Gradle / Ivy

Go to download

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 now versioned in the main HermiT version repository, although not officially supported by the HermiT developers. 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!
/*
 * Created on Apr 9, 2004
 * 
 * $Log: Accessible.java,v $
 * Revision 1.1  2005/03/23 07:22:42  bailly
 * created transductions package
 * corrected EpsilonRemover
 * added some tests
 * removed DirectedGRaph Interface from Automaton
 *
 * Revision 1.2  2004/09/07 10:06:29  bailly
 * cleared imports
 *
 * Revision 1.1  2004/04/09 15:51:50  bailly
 * Added algorithm for computing a mixed word from several automata (to be verified)
 *
 */
package rationals.transformations;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import rationals.Automaton;
import rationals.NoSuchStateException;
import rationals.State;
import rationals.Transition;

/**
 * Compute the automaton accessible from a given state
 * @author bailly
 * @version $Id: Accessible.java 2 2006-08-24 14:41:48Z oqube $
 */
public class Accessible implements UnaryTransformation {

	private State state;

	/**
	 * The state we must start exploration from
	 * 
	 */
	public Accessible(State s) {
		this.state = s;
	}

	/* (non-Javadoc)
	 * @see rationals.transformations.UnaryTransformation#transform(rationals.Automaton)
	 */
	public Automaton transform(Automaton a) {
		Set trs = a.delta();
		Automaton b = new Automaton();
		Map stmap = new HashMap();
		/* initial state = state */
		State ns = b.addState(true,state.isTerminal());
		stmap.put(state,ns);
		explore(state,stmap,a,b);
		/* eplore a and remove transitions from trs */
		Iterator it = trs.iterator();
		while(it.hasNext()) {
			Transition tr = (Transition)it.next();
			State nstart = (State)stmap.get(tr.start());
			State nend = (State)stmap.get(tr.end());
			if((nstart != null) && (nend != null))
				try {
					b.addTransition(new Transition(nstart,tr.label(),nend));
				} catch (NoSuchStateException e) {
					System.err.println(e.getMessage());
					return null;
				}
		}
		return b;
	}

	/**
	 * Recursive function to explore transitions from a state
	 * @param state
	 * @param stmap
	 * @param b
	 */
	private void explore(State curstate, Map stmap, Automaton a,Automaton b) {
		Iterator it = a.delta(curstate).iterator();
		while(it.hasNext()) {
			Transition tr = (Transition)it.next();
			State e= tr.end();
			State ne = (State)stmap.get(e);
			if(ne != null)
				continue;
			else {
				ne = b.addState(e.isInitial(),e.isTerminal());
				stmap.put(e,ne);
				explore(e,stmap,a,b);
			}
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy