<commit_before>package com.yagadi.enguage.sofa;

import com.yagadi.enguage.expression.Colloquial;
import com.yagadi.enguage.expression.Plural;
import com.yagadi.enguage.sofa.tier2.Item;
import com.yagadi.enguage.sofa.tier2.List;
import com.yagadi.enguage.util.Audit;
import com.yagadi.enguage.util.Shell;
import com.yagadi.enguage.util.Strings;

public class Sofa extends Shell {
	static private Audit audit = new Audit( "Sofa", true );

	public Sofa(){ super( "Sofa" );}
	private static final String True  = SUCCESS;
	private static final String False = FAIL;

	public String doCall( Strings a ) {
		//audit.traceIn( "doCall", a.toString( Strings.CSV ));
		if (null != a && a.size() > 1) {
			/* Tags.matchValues() now produces:
			 * 		["a", "b", "c='d'", "e", "f='g'"]
			 * Sofa.interpret() typically deals with:
			 * 		["string", "get", "martin", "name"]
			 * 		["colloquial", "both", "'I have'", "'I've'"]
			 * Need to ensure first 4? name/value pairs are dereferenced
			 * Needs to be done here, as call() will be called independently
			 * May need to be selective on how this is done, depending on sofa 
			 * package class requirements...?
			 */
			for (int i=0; i<5 && i<a.size(); i++)
				a.set( i, Attribute.expandValues( a.get( i ) ).toString( Strings.SPACED ));
			//audit.audit("Sofa.doCall() => a is "+ a.toString());
			//a = a.normalise().contract( "=" );// rejig:"list","get","one two","three four"] => "list","get","one","two","three","four"]
			//audit.debug("Sofa.doCall() => "+ a.toString());
			
			String  type = a.get( 0 );
			return //audit.traceOut(
			    a.size() == 1 && type.equals(         True ) ? True :
				 a.size() == 1 && type.equals(        False ) ? False :
						type.equals(     "entity" ) ?      Entity.interpret( a.copyAfter( 0 ) ) :<commit_msg>Added autoAttach in sofa ctor - perf issues if lots of sofa creation?<commit_after>package com.yagadi.enguage.sofa;

import com.yagadi.enguage.expression.Colloquial;
import com.yagadi.enguage.expression.Plural;
import com.yagadi.enguage.sofa.tier2.Item;
import com.yagadi.enguage.sofa.tier2.List;
import com.yagadi.enguage.util.Audit;
import com.yagadi.enguage.util.Shell;
import com.yagadi.enguage.util.Strings;

public class Sofa extends Shell {
	static private Audit audit = new Audit( "Sofa", true );

	public Sofa(){
		super( "Sofa" );
		if (!Overlay.autoAttach())
			audit.ERROR( "Ouch! in sofa" );
	}
	private static final String True  = SUCCESS;
	private static final String False = FAIL;

	public String doCall( Strings a ) {
		//audit.traceIn( "doCall", a.toString( Strings.CSV ));
		if (null != a && a.size() > 1) {
			/* Tags.matchValues() now produces:
			 * 		["a", "b", "c='d'", "e", "f='g'"]
			 * Sofa.interpret() typically deals with:
			 * 		["string", "get", "martin", "name"]
			 * 		["colloquial", "both", "'I have'", "'I've'"]
			 * Need to ensure first 4? name/value pairs are dereferenced
			 * Needs to be done here, as call() will be called independently
			 * May need to be selective on how this is done, depending on sofa 
			 * package class requirements...?
			 */
			for (int i=0; i<5 && i<a.size(); i++)
				a.set( i, Attribute.expandValues( a.get( i ) ).toString( Strings.SPACED ));
			//audit.audit("Sofa.doCall() => a is "+ a.toString());
			//a = a.normalise().contract( "=" );// rejig:"list","get","one two","three four"] => "list","get","one","two","three","four"]
			//audit.debug("Sofa.doCall() => "+ a.toString());
			
			String  type = a.get( 0 );
			return //audit.traceOut(
			    a.size() == 1 && type.equals(         True ) ? True :
				 a.size() == 1 && type.equals(        False ) ? False :
						type.equals(     "entity" ) ?      Entity.interpret( a.copyAfter( 0 ) ) :
{'fraction_non_alphanumeric': 0.18272335844994617, 'fraction_numerical': 0.005382131324004306, 'mean_word_length': 3.2528604118993134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '4491623', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1316, 'n_words': 341}