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

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

Go to download

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

There is a newer version: 2.4
Show newest version
package jadex.bdi.tutorial;

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


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

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

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

	/**
	 *  Create a new plan.
	 */
	public EnglishFrenchTranslationPlanE1()
	{
		getLogger().info("Created: "+this);
		this.query_word	= getExpression("query_efword");
	}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy