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

jadex.bdi.tutorial.EnglishGermanTranslationPlanE1 Maven / Gradle / Ivy

Go to download

The Jadex BDI applications package contain several example applications, benchmarks and testcases using BDI agents.

The newest version!
package jadex.bdi.tutorial;

import jadex.bdi.runtime.IExpression;
import jadex.bdi.runtime.Plan;


/**
 *  An english german translation plan can translate
 *  english words to german and is instantiated on demand.
 */
public class EnglishGermanTranslationPlanE1 extends Plan
{
	//-------- attributes --------

	/** Query the tuples for a word. */
	protected IExpression	queryword;

	//-------- constructors --------

	/**
	 *  Create a new plan.
	 */
	public EnglishGermanTranslationPlanE1()
	{
		getLogger().info("Created: "+this);
		this.queryword	= getExpression("query_egword");
	}

	//-------- methods --------

	/**
	 *  Execute a plan.
	 */
	public void body()
	{
		String eword = (String)getParameter("word").getValue();
		String gword = (String)queryword.execute("$eword", eword);
		if(gword!=null)
		{
			//getLogger().info("Translating from english to german: "+eword+" - "+gword);
			getParameter("result").setValue(gword);
}
		else
		{
			getLogger().info("Sorry word is not in database: "+eword);
			fail();
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy