<commit_before>/*
 * Copyright 2010 <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://www.apache.org/licenses/LICENSE-2.0 
 * 
 * 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 utility;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Config {
    
    private static String getConfigValue(String line, String varName) {
        
        if (line.indexOf(varName) != -1) {
            
            int rValStart = line.indexOf("=");
            
            if (rValStart > line.indexOf(varName)) {
                return line.substring(rValStart + 1).trim();
            }
        }
        
        return null;
        
    }
    
    public static String readConfig(String key) {
        
        String value = null;

        try {
          
            BufferedReader in = new BufferedReader(new FileReader("config.txt"));  
            <commit_msg>bug fix (3095152): Too tolerant parsing of configuration file<commit_after>/*
 * Copyright 2010 <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://www.apache.org/licenses/LICENSE-2.0 
 * 
 * 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 utility;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Config {
    
    /**
     * Get the value of a configuration variable
     * @param line  A configuration file line
     * @param varName The configuration variable searched for
     * @return The value of the configuration variable if it matches the variable in the current file line, null otherwise
     */
    private static String getConfigValue(String line, String varName) {
        
        String retVal = null;
        
        if (line.indexOf("=") != -1) {
            
            String [] equation = line.split("=");
            
            String lValue = equation[0].trim();
            String rValue = line.substring(line.indexOf("=") + 1).trim();
                
            if (varName.equals(lValue)) {
                retVal = rValue;
            }
        }
        
        return retVal;
        
    }
    
    public static String readConfig(String key) {
        
        String value = null;

        try {
          
            BufferedReader in = new BufferedReader(new FileReader("config.txt"));  
            
{'fraction_non_alphanumeric': 0.08241758241758242, 'fraction_numerical': 0.008547008547008548, 'mean_word_length': 2.187743190661479, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7445110', 'n_tokens_mistral': 864, 'n_tokens_neox': 821, 'n_words': 315}