Main entry point for training.
@throws IOException
throws an exception if errors in the various file inputs.
977565
public final void train() throws IOException {
    // load training parameters file
    final String paramFile = this.parsedArguments.getString("params");
    final TrainingParameters params = InputOutputUtils
        .loadTrainingParameters(paramFile);
    String outModel = null;
    if (params.getSettings().get("OutputModel") == null
        || params.getSettings().get("OutputModel").length() == 0) {
      outModel = Files.getNameWithoutExtension(paramFile) + ".bin";
      params.put("OutputModel", outModel);
    } else {
      outModel = Flags.getModel(params);
    }
    String component = Flags.getComponent(params);
    if (component.equalsIgnoreCase("POS")) {
      final TaggerTrainer posTaggerTrainer = new FixedTrainer(params);
      final POSModel trainedModel = posTaggerTrainer.train(params);
      CmdLineUtil.writeModel("ixa-pipe-pos", new File(outModel), trainedModel);
    } else if (component.equalsIgnoreCase("Lemma")) {
      final LemmatizerTrainer lemmatizerTrainer = new LemmatizerFixedTrainer(params);
      final LemmatizerModel trainedModel = lemmatizerTrainer.train(params);
      CmdLineUtil.writeModel("ixa-pipe-lemma", new File(outModel), trainedModel);
    }
  }
644348
public static void main(String[] args) throws Exception {
        if (args.length > 0) {
            PID p = new PID(args[0]);
            System.out.println("Normalized    : " + p.toString());
            System.out.println("To filename   : " + p.toFilename());
            System.out.println("From filename : "
                    + PID.fromFilename(p.toFilename()).toString());
        } else {
            System.out.println("--------------------------------------");
            System.out.println("PID Syntax Checker - Interactive mode");
            System.out.println("--------------------------------------");
            boolean done = false;
            BufferedReader reader =
                    new BufferedReader(new InputStreamReader(System.in));
            while (!done) {
                try {
                    System.out.print("Enter a PID (ENTER to exit): ");
                    String line = reader.readLine();
                    if (line.isEmpty()) {
                        done = true;
                    } else {
                        PID p = new PID(line);
                        System.out.println("Normalized    : " + p.toString());
                        System.out.println("To filename   : " + p.toFilename());
                        System.out.println("From filename : "
                                + PID.fromFilename(p.toFilename()).toString());
                    }
                } catch (MalformedPIDException e) {
                    System.out.println("ERROR: " + e.getMessage());
                }
            }
        }
    }
170772
public static void main(final String[] args) throws IOException
    {
        // This is just a _hack_ ...
        BufferedReader reader = null;
        if (args.length == 0)
        {
            System.err.println("No input file specified.");
            System.exit(-1);
        }
        if (args.length > 1)
        {
            reader = new BufferedReader(new InputStreamReader(new FileInputStream(args[1]), "UTF-8"));
            String line = reader.readLine();
            while (line != null && !line.startsWith("<!-- ###"))
            {
                System.out.println(line);
                line = reader.readLine();
            }
        }
        System.out.println(Processor.process(new File(args[0])));
        if (args.length > 1 && reader != null)
        {
            String line = reader.readLine();
            while (line != null)
            {
                System.out.println(line);
                line = reader.readLine();
            }
            reader.close();
        }
    }
1185778
public void train(String dataFile, int maxite, float c) throws IOException {

		fp = File.createTempFile("train-features", null, new File("./tmp/"));

		buildInstanceList(dataFile);

		LabelAlphabet postagAlphabet = factory.buildLabelAlphabet("postag");


		SFGenerator generator = new SFGenerator();
		Linear[] models = new Linear[postagAlphabet.size()];

		for (int i = 0; i < postagAlphabet.size(); i++) {
			String pos = postagAlphabet.lookupString(i);
			InstanceSet instset = readInstanceSet(pos);
			LabelAlphabet alphabet = factory.buildLabelAlphabet(pos);
			int ysize = alphabet.size();
			System.out.printf("Training with data: %s\n", pos);
			System.out.printf("Number of labels: %d\n", ysize);
			LinearMax solver = new LinearMax(generator, ysize);
			ZeroOneLoss loss = new ZeroOneLoss();
			Update update = new LinearMaxPAUpdate(loss);
			OnlineTrainer trainer = new OnlineTrainer(solver, update, loss,
					factory, maxite, c);
			models[i] = trainer.train(instset, null);
			instset = null;
			solver = null;
			loss = null;
			trainer = null;
			System.out.println();
		}
		factory.setStopIncrement(true);
		saveModels(modelfile, models,factory);

		fp.delete();
		fp = null;
	}
213614
public static void main(String[] args) throws IOException, TrustyUriException {
		File inputFile = new File(args[0]);
		String baseName = null;
		if (args.length > 1) {
			baseName = args[1];
		}
		transform(inputFile, baseName);
	}
141202
static public void main(String[] sa)
    throws IOException, TarMalformatException {

        if (sa.length < 1) {
            System.out.println(RB.singleton.getString(RB.TARREADER_SYNTAX,
                    TarReader.class.getName()));
            System.out.println(RB.singleton.getString(RB.LISTING_FORMAT));
            System.exit(0);
        }

        File exDir = (sa.length > 1 && sa[1].startsWith("--directory="))
                     ? (new File(sa[1].substring("--directory=".length())))
                     : null;
        int firstPatInd = (exDir == null) ? 2
                                          : 3;

        if (sa.length < firstPatInd
                || ((!sa[0].equals("t")) && !sa[0].equals("x"))) {
            throw new IllegalArgumentException(
                RB.singleton.getString(
                    RB.TARREADER_SYNTAXERR, TarReader.class.getName()));
        }

        String[] patternStrings = null;

        if (sa.length > firstPatInd) {
            patternStrings = new String[sa.length - firstPatInd];

            for (int i = firstPatInd; i < sa.length; i++) {
                patternStrings[i - firstPatInd] = sa[i];
            }
        }

        if (sa[0].equals("t") && exDir != null) {
            throw new IllegalArgumentException(
                RB.singleton.getString(RB.DIR_X_CONFLICT));
        }

        int dirIndex      = (exDir == null) ? 1
                                            : 2;
        int tarReaderMode = sa[0].equals("t") ? LIST_MODE
                                              : EXTRACT_MODE;

        new TarReader(new File(sa[dirIndex]), tarReaderMode, patternStrings,
                      null, exDir).read();
    }
1161313
public void save() throws IOException {
	if (!file.exists()) file.createFile(true);
	OutputStream out = IOUtil.toBufferedOutputStream(file.getOutputStream());
	Iterator it = sections.keySet().iterator();
	PrintWriter output = new PrintWriter(out);
	try {
	    while (it.hasNext()) {
		String strSection = (String) it.next();
		output.println("[" + strSection + "]");
		Map section = getSectionEL(strSection);
		Iterator iit = section.keySet().iterator();
		while (iit.hasNext()) {
		    String key = (String) iit.next();
		    output.println(key + "=" + section.get(key));
		}
	    }
	}
	finally {
	    IOUtil.flushEL(output);
	    IOUtil.closeEL(output);
	    IOUtil.flushEL(out);
	    IOUtil.closeEL(out);
	}
    }
1097030
public static void main(String[] args) throws IOException {

    String encoding = args[1];
    Reader in = new BufferedReader(new InputStreamReader(new FileInputStream(args[0]), encoding));

    Tokenizer<String> st = new CHTBTokenizer(in);

    while (st.hasNext()) {
      String s = st.next();
      EncodingPrintWriter.out.println(s, encoding);
      // EncodingPrintWriter.out.println("|" + s + "| (" + s.length() + ")",
      //				encoding);
    }
  }
1063063
private void init(InputStream in) throws java.io.IOException {
        if (in.available() > 2000000) {
        	throw new IOException("Font too big");
        }
        this.file = IOUtils.toByteArray(in);
        this.fsize = this.file.length;
        if (fsize > 2000000) {
        	throw new IOException("Font too big");
        }
        this.current = 0;
    }
148838
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		// set up the execution environment
		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

		// get input data
		DataStream<String> text;
		if (params.has("input")) {
			// read the text file from given input path
			text = env.readTextFile(params.get("input"));
		} else {
			System.out.println("Executing WindowWordCount example with default input data set.");
			System.out.println("Use --input to specify file input.");
			// get default test text data
			text = env.fromElements(WordCountData.WORDS);
		}

		// make parameters available in the web interface
		env.getConfig().setGlobalJobParameters(params);

		final int windowSize = params.getInt("window", 10);
		final int slideSize = params.getInt("slide", 5);

		DataStream<Tuple2<String, Integer>> counts =
		// split up the lines in pairs (2-tuples) containing: (word,1)
		text.flatMap(new WordCount.Tokenizer())
				// create windows of windowSize records slided every slideSize records
				.keyBy(0)
				.countWindow(windowSize, slideSize)
				// group by the tuple field "0" and sum up tuple field "1"
				.sum(1);

		// emit result
		if (params.has("output")) {
			counts.writeAsText(params.get("output"));
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			counts.print();
		}

		// execute program
		env.execute("WindowWordCount");
	}
1303150
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		// set up the execution environment
		final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

		// make parameters available in the web interface
		env.getConfig().setGlobalJobParameters(params);

		// get input data
		DataSet<String> text;
		if (params.has("input")) {
			// read the text file from given input path
			text = env.readTextFile(params.get("input"));
		} else {
			// get default test text data
			System.out.println("Executing WordCount example with default input data set.");
			System.out.println("Use --input to specify file input.");
			text = WordCountData.getDefaultTextLineDataSet(env);
		}

		DataSet<Tuple2<String, Integer>> counts =
				// split up the lines in pairs (2-tuples) containing: (word,1)
				text.flatMap(new Tokenizer())
				// group by the tuple field "0" and sum up tuple field "1"
				.groupBy(0)
				.sum(1);

		// emit result
		if (params.has("output")) {
			counts.writeAsCsv(params.get("output"), "\n", " ");
			// execute program
			env.execute("WordCount Example");
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			counts.print();
		}

	}
1155475
public void startMonitoring()
    throws IOException 
  {
    if (file == null) {
      writer = new PrintWriter(new BufferedOutputStream(System.out));
    } else {
      writer = new PrintWriter(new FileWriter(file, true));
    }
    super.startMonitoring();
  }
501873
public static void main(String[] args) throws IOException {
    	String infile = "../example-data/data-lda.txt";
    	String stopwordfile = "../models/stopwords/stopwords.txt";
		BufferedReader in = new BufferedReader(new InputStreamReader(
				new FileInputStream(infile ), "utf8"));

		//		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
//				outfile), enc2));
		StopWords sw = new StopWords(stopwordfile);
		
		LabelAlphabet dict = new LabelAlphabet();
		// words in documents
		ArrayList<TIntArrayList> documentsList= new ArrayList<TIntArrayList>();
		
		
		String line = null;
		while ((line = in.readLine()) != null) {
			line = line.trim();	
			if(line.length()==0)
				continue;
			String[] toks = line.split("\\s+");
			TIntArrayList wordlist = new TIntArrayList(); 
			for(int j=0;j<toks.length;j++){
				String tok = toks[j];
				if(sw.isStopWord(tok))
					continue;
				int idx = dict.lookupIndex(tok);
				wordlist.add(idx);
			}
			documentsList.add(wordlist);
		}
		in.close();
		int[][] documents;
		documents = new int[documentsList.size()][];
		for(int i=0;i<documents.length;i++){
			documents[i] = documentsList.get(i).toArray();
		}
        // vocabulary
        int V = dict.size();
        int M = documents.length;
        // # topics
        int K = 4;
        // good values alpha = 2, beta = .5
        float alpha = 2f;
        float beta = .5f;

        System.out.println("Latent Dirichlet Allocation using Gibbs Sampling.");

        LdaGibbsSampler lda = new LdaGibbsSampler(documents, V);
        lda.configure(10000, 2000, 100, 10);
        lda.gibbs(K, alpha, beta);

        float[][] theta = lda.getTheta();
        float[][] phi = lda.getPhi();

        System.out.println();
        System.out.println();
        System.out.println("Document--Topic Associations, Theta[d][k] (alpha="
            + alpha + ")");
        System.out.print("d\\k\t");
        for (int m = 0; m < theta[0].length; m++) {
            System.out.print("   " + m % 10 + "    ");
        }
        System.out.println();
        for (int m = 0; m < theta.length; m++) {
            System.out.print(m + "\t");
            for (int k = 0; k < theta[m].length; k++) {
                // System.out.print(theta[m][k] + " ");
                System.out.print(shadefloat(theta[m][k], 1) + " ");
            }
            System.out.println();
        }
        System.out.println();
        System.out.println("Topic--Term Associations, Phi[k][w] (beta=" + beta
            + ")");

        System.out.print("k\\w\t");
        for (int w = 0; w < phi[0].length; w++) {
            System.out.print("   " + dict.lookupString(w) + "    ");
        }
        System.out.println();
        for (int k = 0; k < phi.length; k++) {
            System.out.print(k + "\t");
            for (int w = 0; w < phi[k].length; w++) {
            	System.out.print(lnf.format(phi[k][w]) + " ");
//            	System.out.print(phi[k][w] + " ");
//                System.out.print(shadefloat(phi[k][w], 1) + " ");
            }
            System.out.println();
        }
        for (int k = 0; k < phi.length; k++) {
        	int[] top = MyArrays.sort(phi[k]);
        	
            for (int w = 0; w < 10; w++) {
            	System.out.print(dict.lookupString(top[w]) + " ");
            }
            System.out.println();
        }
    }
1360157
def main():
    """"""

    options, input_file = _parse_options()

    if (options.debug):
        run(input_file, options)
    else:
        try:
            run(input_file, options)
        except Exception as e:
            sys.stderr.write("Error: %s\n" % e)
            sys.exit(1)
969884
public static void main(String[] args) throws Exception {

		// Checking input parameters
		final ParameterTool params = ParameterTool.fromArgs(args);

		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);

		DataStream<Integer> trainingData = env.addSource(new FiniteTrainingDataSource());
		DataStream<Integer> newData = env.addSource(new FiniteNewDataSource());

		// build new model on every second of new data
		DataStream<Double[]> model = trainingData
				.assignTimestampsAndWatermarks(new LinearTimestamp())
				.timeWindowAll(Time.of(5000, TimeUnit.MILLISECONDS))
				.apply(new PartialModelBuilder());

		// use partial model for newData
		DataStream<Integer> prediction = newData.connect(model).map(new Predictor());

		// emit result
		if (params.has("output")) {
			prediction.writeAsText(params.get("output"));
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			prediction.print();
		}

		// execute program
		env.execute("Streaming Incremental Learning");
	}
132396
public static void main(String... argv) throws IOException {
    run(System.out, argv);
    System.out.println();
  }
290382
public static void main(String[] args) throws IOException
    {
        process_command_line(args);

        info = new JarInfo();

        if (printVersion) {
            doPrintVersion();
        }
        if (printHelp) {
            doPrintHelp();
        }
    }