<commit_before>package cal;

import java.io.File;

public class ParserFactory {

    /*
     * Classify whether the user input are: 1. expression 2. equation 3.
     * input file path Read the user input from input file path
     */
	public Parser createParser(String str) {
	    String input = str;
		if (isExpression(input)) {
			return new ExpressionTree();
		} else if (isEquation(input)) {
			// TODO: create equation tree for calculation
			return new NullParser();
		} else if (isFilePath(input)) {
			// TODO: read user input from file path
		      // check input isEquation/isExpression again
			return new NullParser();
		} else
			return new NullParser();
	}
	
	// XXX move to BasicMathMethod
	public boolean isExpression(String str) {
		str = str.replace(" ", "");
		if (str.isEmpty())
		  return false;
		
		String num = "[\\-\\+]?[0-9]*\\.?[0-9]+";
		String op = "([\\/\\+\\-\\*\\^])";
	    String exp = "\\(*" + num + "\\)*("+op+"\\(*"+num+"\\)*)*";
		
		return str.matches(exp);
	}

	private boolean isEquation(String str) {
		// TODO check equation
		str = str.replace(" ", "");
		if (str.isEmpty())
			return false;
		else
			return false; 
	}

	private boolean isFilePath(String str) {
		return new File(str).exists();
	}
}
<commit_msg>Add comment java doc into the class of ParserFactory<commit_after>package cal;

import java.io.File;

public class ParserFactory {
	/**
	 * To determine the input string whether 
	 * it is expression, equation and file path.
	 * 
	 * @param str accept string input
	 * @return Parser object
	 */
    /*
     * Classify whether the user input are: 1. expression 2. equation 3.
     * input file path Read the user input from input file path
     */
	public Parser createParser(String str) {
	    String input = str;
		if (isExpression(input)) {
			return new ExpressionTree();
		} else if (isEquation(input)) {
			// TODO: create equation tree for calculation
			return new NullParser();
		} else if (isFilePath(input)) {
			// TODO: read user input from file path
		      // check input isEquation/isExpression again
			return new NullParser();
		} else
			return new NullParser();
	}
	
	// XXX move to BasicMathMethod
	public boolean isExpression(String str) {
		str = str.replace(" ", "");
		if (str.isEmpty())
		  return false;
		
		String num = "[\\-\\+]?[0-9]*\\.?[0-9]+";
		String op = "([\\/\\+\\-\\*\\^])";
	    String exp = "\\(*" + num + "\\)*("+op+"\\(*"+num+"\\)*)*";
		
		return str.matches(exp);
	}

	private boolean isEquation(String str) {
		// TODO check equation
		str = str.replace(" ", "");
		if (str.isEmpty())
			return false;
		else
			return false; 
	}

	private boolean isFilePath(String str) {
		return new File(str).exists();
	}
}

{'fraction_non_alphanumeric': 0.1570217471433837, 'fraction_numerical': 0.005160339107998526, 'mean_word_length': 2.7905027932960893, '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': '1974684', 'n_tokens_mistral': 955, 'n_tokens_neox': 831, 'n_words': 273}