<commit_before>package org.openhab.io.context.interpretation;

import org.openhab.core.library.types.ContextType;
import org.openhab.io.context.ContextService;
import org.openhab.io.context.primitives.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ContextChangeInterpreter {
	private static final Logger logger = LoggerFactory.getLogger(ContextService.class);
	
	public String getContextAsString(ContextType t)
	{
		switch(t) {
	    case AT_HOME       :                 return "AT_HOME";
	    case NOT_AT_HOME   :                 return "NOT_AT_HOME";
	    case AT_HOME_SOCIAL:                 return "AT_HOME_SOCIAL";
	    case AT_HOME_SLEEP :                 return "AT_HOME_SLEEP";
	    case AT_HOME_WORK  :                 return "AT_HOME_WORK";
	    case AT_HOME_SCHOOL:                 return "AT_HOME_SCHOOL";
	    case NOT_AT_HOME_HOLIDAYS:           return "NOT_AT_HOME_HOLIDAYS";
	    case NOT_AT_HOME_SCHOOL:             return "NOT_AT_HOME_SCHOOL";
	    case NOT_AT_HOME_SHOPPING:           return "NOT_AT_HOME_SHOPPING";
    	case NOT_AT_HOME_SOCIAL:             return "NOT_AT_HOME_SOCIAL";
	    case NOT_AT_HOME_SOCIAL_CINEMA:      return "NOT_AT_HOME_SOCIAL_CINEMA";
	    case NOT_AT_HOME_SOCIAL_DINING:      return "NOT_AT_HOME_SOCIAL_DINING";
	    case NOT_AT_HOME_TRAVELING:          return "NOT_AT_HOME_TRAVELING";
	    case NOT_AT_HOME_TRAVELING_HOLIDAYS: return "NOT_AT_HOME_TRAVELING_HOLIDAYS";
	    case NOT_AT_HOME_TRAVELING_HOME:     return "NOT_AT_HOME_TRAVELING_HOME";
	    case NOT_AT_HOME_TRAVELING_SCHOOL:   return "NOT_AT_HOME_TRAVELING_SCHOOL";
	    case NOT_AT_HOME_TRAVELING_SHOPPING: return "NOT_AT_HOME_TRAVELING_SHOPPING";
	    case NOT_AT_HOME_TRAVELING_SOCIAL:   return "NOT_AT_HOME_TRAVELING_SOCIAL";
	    case NOT_AT_HOME_TRAVELING_WORK:     return "NOT_AT_HOME_TRAVELING_WORK";
	    case NOT_AT_HOME_WORK:               return "NOT_AT_HOME_WORK";
	    default:
	}
	return "LIMBO";		
	}
	
	
	
	public ContextType getContext(User u) {
		ContextType context = null;
		ContextCriteriaFactory fact = new ContextCriteriaFactory();
		if(fact.getCriteria(ContextType.AT_HOME).meetsCriteria(u)) {
			context = ContextType.AT_HOME;
			logger.info(u.getName()+" matched criteria ContextType.AT_HOME;");
			if(fact.getCriteria(ContextType.AT_HOME_SOCIAL).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SOCIAL;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_SOCIAL;");
			}
			else if(fact.getCriteria(ContextType.AT_HOME_SLEEP).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SLEEP;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_SLEEP;");
			}
			else if(fact.getCriteria(ContextType.AT_HOME_WORK).meetsCriteria(u)) {
				context = ContextType.AT_HOME_WORK;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_WORK;");
			}
			else if(fact.getCriteria(ContextType.AT_HOME_SCHOOL).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SCHOOL;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_SCHOOL;");
			}
		}
		else if(fact.getCriteria(ContextType.NOT_AT_HOME).meetsCriteria(u)) {
			context = ContextType.NOT_AT_HOME;
			logger.info(u.getName()+" matched criteria ContextType.NOT_AT_HOME;");
			if(fact.getCriteria(ContextType.NOT_AT_HOME_SOCIAL).meetsCriteria(u)) {
				context = ContextType.NOT_AT_HOME_SOCIAL;
			}<commit_msg>Adding extra context checks to decision tree<commit_after>package org.openhab.io.context.interpretation;

import org.openhab.core.library.types.ContextType;
import org.openhab.io.context.ContextService;
import org.openhab.io.context.primitives.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ContextChangeInterpreter {
	private static final Logger logger = LoggerFactory.getLogger(ContextService.class);
	
	public String getContextAsString(ContextType t)
	{
		switch(t) {
	    case AT_HOME       :                 return "AT_HOME";
	    case NOT_AT_HOME   :                 return "NOT_AT_HOME";
	    case AT_HOME_SOCIAL:                 return "AT_HOME_SOCIAL";
	    case AT_HOME_SLEEP :                 return "AT_HOME_SLEEP";
	    case AT_HOME_WORK  :                 return "AT_HOME_WORK";
	    case AT_HOME_SCHOOL:                 return "AT_HOME_SCHOOL";
	    case NOT_AT_HOME_HOLIDAYS:           return "NOT_AT_HOME_HOLIDAYS";
	    case NOT_AT_HOME_SCHOOL:             return "NOT_AT_HOME_SCHOOL";
	    case NOT_AT_HOME_SHOPPING:           return "NOT_AT_HOME_SHOPPING";
    	case NOT_AT_HOME_SOCIAL:             return "NOT_AT_HOME_SOCIAL";
	    case NOT_AT_HOME_SOCIAL_CINEMA:      return "NOT_AT_HOME_SOCIAL_CINEMA";
	    case NOT_AT_HOME_SOCIAL_DINING:      return "NOT_AT_HOME_SOCIAL_DINING";
	    case NOT_AT_HOME_TRAVELING:          return "NOT_AT_HOME_TRAVELING";
	    case NOT_AT_HOME_TRAVELING_HOLIDAYS: return "NOT_AT_HOME_TRAVELING_HOLIDAYS";
	    case NOT_AT_HOME_TRAVELING_HOME:     return "NOT_AT_HOME_TRAVELING_HOME";
	    case NOT_AT_HOME_TRAVELING_SCHOOL:   return "NOT_AT_HOME_TRAVELING_SCHOOL";
	    case NOT_AT_HOME_TRAVELING_SHOPPING: return "NOT_AT_HOME_TRAVELING_SHOPPING";
	    case NOT_AT_HOME_TRAVELING_SOCIAL:   return "NOT_AT_HOME_TRAVELING_SOCIAL";
	    case NOT_AT_HOME_TRAVELING_WORK:     return "NOT_AT_HOME_TRAVELING_WORK";
	    case NOT_AT_HOME_WORK:               return "NOT_AT_HOME_WORK";
	    default:
	}
	return "LIMBO";		
	}
	
	
	public ContextType getContext(User u) {
		ContextType context = null;
		ContextCriteriaFactory fact = new ContextCriteriaFactory();
		if(fact.getCriteria(ContextType.AT_HOME).meetsCriteria(u)) {
			context = ContextType.AT_HOME;
			if(fact.getCriteria(ContextType.AT_HOME_SOCIAL).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SOCIAL;
			}
			else if(fact.getCriteria(ContextType.AT_HOME_SLEEP).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SLEEP;
			}
			else if(fact.getCriteria(ContextType.AT_HOME_WORK).meetsCriteria(u)) {
				context = ContextType.AT_HOME_WORK;
			}
			else if(fact.getCriteria(ContextType.AT_HOME_SCHOOL).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SCHOOL;
			}
		}
		else if(fact.getCriteria(ContextType.NOT_AT_HOME).meetsCriteria(u)) {
			context = ContextType.NOT_AT_HOME;
			if(fact.getCriteria(ContextType.NOT_AT_HOME_SOCIAL).meetsCriteria(u)) {
				context = ContextType.NOT_AT_HOME_SOCIAL;
			}
			else if(fact.getCriteria(ContextType.NOT_AT_HOME_WORK).meetsCriteria(u)) {
				context = ContextType.NOT_AT_HOME_WORK;
			}
			else if(fact.getCriteria(ContextType.NOT_AT_HOME_SCHOOL).meetsCriteria(u)) {
				context = ContextType.NOT_AT_HOME_SCHOOL;
			}
			else if(fact.getCriteria(ContextType.NOT_AT_HOME_SHOPPING).meetsCriteria(u)) {
				context = ContextType.NOT_AT_HOME_SHOPPING;
			}
			else if(fact.getCriteria(ContextType.NOT_AT_HOME_TRAVELING).meetsCriteria(u)) {
				context = ContextType.NOT_AT_HOME_TRAVELING;
				if(fact.getCriteria(ContextType.NOT_AT_HOME_TRAVELING_HOME).meetsCriteria(u)) {
					context = ContextType.NOT_AT_HOME_TRAVELING_HOME;
				}
				else if(fact.getCriteria(ContextType.NOT_AT_HOME_TRAVELING_WORK).meetsCriteria(u)) {
					context = ContextType.NOT_AT_HOME_TRAVELING_HOME;
				}
				else if(fact.getCriteria(ContextType.NOT_AT_HOME_TRAVELING_SCHOOL).meetsCriteria(u)) {
					context = ContextType.NOT_AT_HOME_TRAVELING_HOME;
				}
				else if(fact.getCriteria(ContextType.NOT_AT_HOME_TRAVELING_SOCIAL).meetsCriteria(u)) {
					context = ContextType.NOT_AT_HOME_TRAVELING_HOME;
				}
				else if(fact.getCriteria(ContextType.NOT_AT_HOME_TRAVELING_SHOPPING).meetsCriteria(u)) {
					context = ContextType.NOT_AT_HOME_TRAVELING_HOME;
				}
			}
		}
        return context;
	}
	public ContextType getContext1(User u) {
		ContextType context = null;
		ContextCriteriaFactory fact = new ContextCriteriaFactory();
		if(fact.getCriteria(ContextType.AT_HOME).meetsCriteria(u)) {
			context = ContextType.AT_HOME;
			logger.info(u.getName()+" matched criteria ContextType.AT_HOME;");
			if(fact.getCriteria(ContextType.AT_HOME_SOCIAL).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SOCIAL;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_SOCIAL;");
			}
			else if(fact.getCriteria(ContextType.AT_HOME_SLEEP).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SLEEP;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_SLEEP;");
			}
			else if(fact.getCriteria(ContextType.AT_HOME_WORK).meetsCriteria(u)) {
				context = ContextType.AT_HOME_WORK;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_WORK;");
			}
			else if(fact.getCriteria(ContextType.AT_HOME_SCHOOL).meetsCriteria(u)) {
				context = ContextType.AT_HOME_SCHOOL;
				logger.info(u.getName()+" matched criteria ContextType.AT_HOME_SCHOOL;");
			}
		}
		else if(fact.getCriteria(ContextType.NOT_AT_HOME).meetsCriteria(u)) {
			context = ContextType.NOT_AT_HOME;
			logger.info(u.getName()+" matched criteria ContextType.NOT_AT_HOME;");
			if(fact.getCriteria(ContextType.NOT_AT_HOME_SOCIAL).meetsCriteria(u)) {
				context = ContextType.NOT_AT_HOME_SOCIAL;
			}
{'fraction_non_alphanumeric': 0.0939812258420762, 'fraction_numerical': 0.0005521811154058532, 'mean_word_length': 4.219596541786744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2022147', 'n_tokens_mistral': 3531, 'n_tokens_neox': 3186, 'n_words': 417}