<commit_before>/*
 * Copyright 2007 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://jamocha.sourceforge.net/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jamocha.adapter.sl.performative;

import org.jamocha.adapter.AdapterTranslationException;

/**
 * This class walks through an SL code tree and translates it to CLIPS depending
 * on the given performative.
 * 
 * @author <NAME>
 * 
 */
public class Proxy {

	/**
	 * A private constructor to force access only in a static way.
	 * 
	 */
	private Proxy() {
	}

	/**
	 * Translates SL code of a request to CLIPS code. A request only contains
	 * one action.
	 * 
	 * @param slContent
	 *            The SL content we have to translate.
	 * @return CLIPS commands that represent the given SL code.
	 * @throws AdapterTranslationException
	 *             if the SLParser throws an Exception or anything else unnormal
	 *             happens.
	 */
	public static String getCLIPS(String slContent)
			throws AdapterTranslationException {
		// TODO: implement me
		return null;
	}

}
<commit_msg>modified the proxy speechact <commit_after>/*
 * Copyright 2007 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://jamocha.sourceforge.net/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jamocha.adapter.sl.performative;

import java.util.List;

import org.jamocha.adapter.AdapterTranslationException;
import org.jamocha.adapter.sl.configurations.ActionSLConfiguration;
import org.jamocha.adapter.sl.configurations.ContentSLConfiguration;
import org.jamocha.adapter.sl.configurations.FunctionCallOrFactSLConfiguration;
import org.jamocha.adapter.sl.configurations.IdentifyingExpressionSLConfiguration;
import org.jamocha.adapter.sl.configurations.SLCompileType;
import org.jamocha.adapter.sl.configurations.SLConfiguration;
import org.jamocha.parser.sl.ParseException;
import org.jamocha.parser.sl.SLParser;

/**
 * This class walks through an SL code tree and translates it to CLIPS depending
 * on the given performative.
 * 
 * @author <NAME>
 * 
 */
public class Proxy {

	/**
	 * A private constructor to force access only in a static way.
	 * 
	 */
	private Proxy() {
	}

	/**
	 * Translates SL code of a proxy to CLIPS code. A proxy only contains
	 * a tuple of referential expression.
	 * 
	 * @param slContent
	 *            The SL content we have to translate.
	 * @return CLIPS commands that represent the given SL code.
	 * @throws AdapterTranslationException
	 *             if the SLParser throws an Exception or anything else unnormal
	 *             happens.
	 */
	public static String getCLIPS(String slContent)
	throws AdapterTranslationException {
		ContentSLConfiguration contentConf;
		try {
			contentConf = SLParser.parse(slContent);
		} catch (ParseException e) {
			throw new AdapterTranslationException(
					"Could not translate from SL to CLIPS.", e);
		}
		List<SLConfiguration> results = contentConf.getExpressions();
		if (results.size() != 1) {
			// TODO: Add more Exceptions for different things extending
			// AdapterTranslationException that tell more about the nature of
			// the problem!
			throw new AdapterTranslationException("Error");
		}
		StringBuilder result = new StringBuilder();
		IdentifyingExpressionSLConfiguration conf = (IdentifyingExpressionSLConfiguration) results
				.get(0);
		String refOp = conf.getRefOp().compile(SLCompileType.RULE_LHS);
		String binding = conf.getTermOrIE().compile(
				SLCompileType.RULE_RESULT);
		result.append("(bind ?*proxy-temp* (create$))");
		result.append("(defrule proxy ");
		result.append(conf.getWff().compile(SLCompileType.RULE_LHS));
		result.append(" => ");
		result.append("(bind ?*proxy-temp* (insert-list$ ?*proxy-temp* 1 ");
		result.append(binding);
		result.append(")))");
		result.append("(fire)");
		result.append("(undefrule \"proxy\")");
		
		ActionSLConfiguration actConf = (ActionSLConfiguration) results.get(1);
		FunctionCallOrFactSLConfiguration functionConf = (FunctionCallOrFactSLConfiguration) actConf
				.getAction();
		String performative = functionConf.getName().compile(
				SLCompileType.ASSERT);
		String oldContent = functionConf.getSlot("content",
				SLCompileType.ASSERT).compile(SLCompileType.ASSERT);

		if (oldContent != null){
			result.append("(assert (agent-proxy-result (message %MSG%)(performative \"");
			result.append(performative);
			result.append("\")(messageContent ");
			result.append(oldContent);
			result.append(")(refOp ");
			result.append(refOp);
			result.append(")(agents ?*proxy-temp*)))");
		}
		System.out.println(result);
		return result.toString();
	}

}

{'fraction_non_alphanumeric': 0.10038539181501192, 'fraction_numerical': 0.0029363185905670764, 'mean_word_length': 3.9545454545454546, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5213622', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1469, 'n_words': 493}