<commit_before>package org.ndexbio.cx2.converter;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * Copied from StringPaser class in cx_support 
 * @author jingchen
 *
 */
public class MappingValueStringParser {
	   private final Map<String, String> _data = new HashMap<>(); 
	     
	    private static final Pattern p0 = Pattern.compile("(?<=(^|,))([^,]|,,)*(?=(,|$))"); 
	 
	    private static final Pattern p = Pattern.compile("^((K|V|L|E|G|OV)=([0-9]+))=(.*)$"); 
	 
	    public static List<String> commaDelimitedListStringToStringList2(String list) { 
	 
	        Matcher matcher = p0.matcher(list); 
	        ArrayList<String> result = new ArrayList<>(); 
	        while (matcher.find()) { 
	            String v = matcher.group(); 
	            if ( v.length() > 0 ) 
	              result.add(v); 
	        } 
	        return result; 
	    } 
	 
	    public MappingValueStringParser(final String str) throws IOException { 
	       
	        List<String> array = commaDelimitedListStringToStringList2(str); 
	        for( String n : array) { 
	            if(n.startsWith("COL=")) { 
	              String v = n.substring(4); 
	              _data.put("COL", v.replace(",,", ",")); 
	            } else if ( n.startsWith("T=")) { 
	              String v = n.substring(2); 
	              _data.put("T", v.replace(",,", ","));              
	            } else { 
	              Matcher m = p.matcher(n); 
	              if ( !m.matches()) 
	                throw new IOException ("Failed to parse mapping string '"+ n + "' in mapping " + str); 
	 
	              _data.put(m.group(1), m.group(4).replace(",,", ",")); 
	            }  
	 
	        } 
	    } <commit_msg>Adding period at the end of error message.<commit_after>package org.ndexbio.cx2.converter;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * Copied from StringPaser class in cx_support 
 * @author jingchen
 *
 */
public class MappingValueStringParser {
	   private final Map<String, String> _data = new HashMap<>(); 
	     
	    private static final Pattern p0 = Pattern.compile("(?<=(^|,))([^,]|,,)*(?=(,|$))"); 
	 
	    private static final Pattern p = Pattern.compile("^((K|V|L|E|G|OV)=([0-9]+))=(.*)$"); 
	 
	    public static List<String> commaDelimitedListStringToStringList2(String list) { 
	 
	        Matcher matcher = p0.matcher(list); 
	        ArrayList<String> result = new ArrayList<>(); 
	        while (matcher.find()) { 
	            String v = matcher.group(); 
	            if ( v.length() > 0 ) 
	              result.add(v); 
	        } 
	        return result; 
	    } 
	 
	    public MappingValueStringParser(final String str) throws IOException { 
	       
	        List<String> array = commaDelimitedListStringToStringList2(str); 
	        for( String n : array) { 
	            if(n.startsWith("COL=")) { 
	              String v = n.substring(4); 
	              _data.put("COL", v.replace(",,", ",")); 
	            } else if ( n.startsWith("T=")) { 
	              String v = n.substring(2); 
	              _data.put("T", v.replace(",,", ","));              
	            } else { 
	              Matcher m = p.matcher(n); 
	              if ( !m.matches()) 
	                throw new IOException ("Failed to parse mapping segment '"+ n + "' in mapping " + str + "."); 
	 
	              _data.put(m.group(1), m.group(4).replace(",,", ",")); 
	            }  
	 
	        } 
	    } 
{'fraction_non_alphanumeric': 0.1557421451787649, 'fraction_numerical': 0.0065005417118093175, 'mean_word_length': 1.9975649350649352, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '3751769', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1080, 'n_words': 239}