<commit_before>package org.networklibrary.primer;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.networklibrary.core.config.ConfigManager;
import org.networklibrary.primer.config.PrimerConfigManager;

/**
 * Hello world!
 *
 */
public class App 
{
	protected static final Logger log = Logger.getLogger(App.class.getName());
	
	public static void main( String[] args )
	{

		Options options = new Options();
		Option help = OptionBuilder.withDescription("Help message").create("help");
		Option dbop = OptionBuilder.withArgName("[URL]").hasArg().withDescription("Neo4j instance to prime").withLongOpt("target").withType(String.class).create("db");
		Option typeop = OptionBuilder.withArgName("[TYPE]").hasArg().withDescription("Types available:").withType(String.class).create("t");
		Option configOp = OptionBuilder.hasArg().withDescription("Alternative config file").withLongOpt("config").withType(String.class).create("c");
		Option extraOps = OptionBuilder.hasArgs().withDescription("Extra configuration parameters for the import").withType(String.class).create("x");

		Option noindexOps = new Option("no_index",false,"index the data");
		Option noarrayOps = new Option("no_array",false,"enforces that no arrays are used as property values");
		Option labelOps = new Option("label",false,"provided values are used as labels for the node");
		Option nopropOps = new Option("no_prop",false,"values are not saved as properties (but as labels if <label> flag is set)");
		Option nonewOps = new Option("no_new_nodes",false,"unknown primary ids will NOT create new nodes");
		Option allowMultiOps = new Option("allow_multi",false, "allow for multiple nodes to be returned on searching");

		options.addOption(help);
		options.addOption(dbop);
		options.addOption(typeop);
		options.addOption(configOp);
		options.addOption(extraOps);

		options.addOption(noindexOps);
		options.addOption(noarrayOps);
		options.addOption(labelOps);
		options.addOption(nopropOps);
		options.addOption(nonewOps);
		options.addOption(allowMultiOps);

		CommandLineParser parser = new GnuParser();
		try {
			CommandLine line = parser.parse( options, args );

			if(line.hasOption("help") || args.length == 0){
				HelpFormatter formatter = new HelpFormatter();
				formatter.printHelp( "netlibprimer [OPTIONS] [FILES]", options );
				return;
			}

			String db = null;
			if(line.hasOption("db")){
				db = line.getOptionValue("db");
			}

			String config = null;
			if(line.hasOption("c")){
				config = line.getOptionValue("c");
			}

			List<String> extras = null;
			if(line.hasOption("x")){
				extras = Arrays.asList(line.getOptionValues("x"));
			}
			
			String type = null;
			if(line.hasOption("t")){
				type = line.getOptionValue("t","TAB");
			}
			
			boolean label = line.hasOption("label");
			boolean index = !line.hasOption("no_index");
			boolean array = !line.hasOption("no_array");
			boolean prop = !line.hasOption("no_prop");
			boolean noNew = line.hasOption("no_new_nodes");
			boolean allowMulti = line.hasOption("allow_multi");

			List<String> inputFiles = line.getArgList();

			PrimerConfigManager confMgr = null;
			
			if(config != null && !config.isEmpty()){
				log.info("user-supplied config file available: ignoring config command line arguments");
				confMgr = new PrimerConfigManager(config);
			} else {
				confMgr = new PrimerConfigManager(type,label,index,array,prop,noNew,allowMulti);

			}
			
			Primer p = new Primer(db,confMgr,inputFiles,extras);<commit_msg>default to parser "TAB" if no argument supplied<commit_after>package org.networklibrary.primer;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.networklibrary.core.config.ConfigManager;
import org.networklibrary.primer.config.PrimerConfigManager;

/**
 * Hello world!
 *
 */
public class App 
{
	protected static final Logger log = Logger.getLogger(App.class.getName());
	
	public static void main( String[] args )
	{

		Options options = new Options();
		Option help = OptionBuilder.withDescription("Help message").create("help");
		Option dbop = OptionBuilder.withArgName("[URL]").hasArg().withDescription("Neo4j instance to prime").withLongOpt("target").withType(String.class).create("db");
		Option typeop = OptionBuilder.withArgName("[TYPE]").hasArg().withDescription("Types available:").withType(String.class).create("t");
		Option configOp = OptionBuilder.hasArg().withDescription("Alternative config file").withLongOpt("config").withType(String.class).create("c");
		Option extraOps = OptionBuilder.hasArgs().withDescription("Extra configuration parameters for the import").withType(String.class).create("x");

		Option noindexOps = new Option("no_index",false,"index the data");
		Option noarrayOps = new Option("no_array",false,"enforces that no arrays are used as property values");
		Option labelOps = new Option("label",false,"provided values are used as labels for the node");
		Option nopropOps = new Option("no_prop",false,"values are not saved as properties (but as labels if <label> flag is set)");
		Option nonewOps = new Option("no_new_nodes",false,"unknown primary ids will NOT create new nodes");
		Option allowMultiOps = new Option("allow_multi",false, "allow for multiple nodes to be returned on searching");

		options.addOption(help);
		options.addOption(dbop);
		options.addOption(typeop);
		options.addOption(configOp);
		options.addOption(extraOps);

		options.addOption(noindexOps);
		options.addOption(noarrayOps);
		options.addOption(labelOps);
		options.addOption(nopropOps);
		options.addOption(nonewOps);
		options.addOption(allowMultiOps);

		CommandLineParser parser = new GnuParser();
		try {
			CommandLine line = parser.parse( options, args );

			if(line.hasOption("help") || args.length == 0){
				HelpFormatter formatter = new HelpFormatter();
				formatter.printHelp( "netlibprimer [OPTIONS] [FILES]", options );
				return;
			}

			String db = null;
			if(line.hasOption("db")){
				db = line.getOptionValue("db");
			}

			String config = null;
			if(line.hasOption("c")){
				config = line.getOptionValue("c");
			}

			List<String> extras = null;
			if(line.hasOption("x")){
				extras = Arrays.asList(line.getOptionValues("x"));
			}
			
			String type = "TAB";
			if(line.hasOption("t")){
				type = line.getOptionValue("t","TAB");
			}
			
			boolean label = line.hasOption("label");
			boolean index = !line.hasOption("no_index");
			boolean array = !line.hasOption("no_array");
			boolean prop = !line.hasOption("no_prop");
			boolean noNew = line.hasOption("no_new_nodes");
			boolean allowMulti = line.hasOption("allow_multi");

			List<String> inputFiles = line.getArgList();

			PrimerConfigManager confMgr = null;
			
			if(config != null && !config.isEmpty()){
				log.info("user-supplied config file available: ignoring config command line arguments");
				confMgr = new PrimerConfigManager(config);
			} else {
				confMgr = new PrimerConfigManager(type,label,index,array,prop,noNew,allowMulti);

			}
			
			Primer p = new Primer(db,confMgr,inputFiles,extras);
{'fraction_non_alphanumeric': 0.13679786014520443, 'fraction_numerical': 0.0005094892370398676, 'mean_word_length': 5.124804992199688, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1078713', 'n_tokens_mistral': 2601, 'n_tokens_neox': 2318, 'n_words': 514}