对文件进行分词，保留停用词
使用双向最大匹配算法
@param input 输入文件
@param output 输出文件
@throws Exception
181220
public static void segWithStopWords(File input, File output) throws Exception{
        Utils.seg(input, output, false, SegmentationAlgorithm.MaxNgramScore);
    }
403080
@Override
  public void writeOutput(VisualizerInput input, OutputStream outstream)
  {
    try
    {
      OutputStreamWriter writer = new OutputStreamWriter(outstream, getCharacterEncoding());
      writeOutput(input, writer);
      writer.flush();
    }
    catch(IOException ex)
    {
      log.error("Exception when writing visualizer output.", ex);
      StringWriter strWriter = new StringWriter();
      ex.printStackTrace(new PrintWriter(strWriter));
      try
      {
        outstream.write(strWriter.toString().getBytes("UTF-8"));
      }
      catch (IOException ex1)
      {
        log.error(null, ex);
      }
    }
  }
702292
@Override
    public void dump(OutputStream output) {
        try (PrintWriter out = new PrintWriter(new OutputStreamWriter(output, UTF_8))) {
            for (long value : values) {
                out.printf("%d%n", value);
            }
        }
    }
1219247
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
		env.getConfig().setGlobalJobParameters(params);

		@SuppressWarnings({"rawtypes", "serial"})
		DataStream<Tuple4<Integer, Integer, Double, Long>> carData;
		if (params.has("input")) {
			carData = env.readTextFile(params.get("input")).map(new ParseCarData());
		} else {
			System.out.println("Executing TopSpeedWindowing example with default input data set.");
			System.out.println("Use --input to specify file input.");
			carData = env.addSource(CarSource.create(2));
		}

		int evictionSec = 10;
		double triggerMeters = 50;
		DataStream<Tuple4<Integer, Integer, Double, Long>> topSpeeds = carData
				.assignTimestampsAndWatermarks(new CarTimestamp())
				.keyBy(0)
				.window(GlobalWindows.create())
				.evictor(TimeEvictor.of(Time.of(evictionSec, TimeUnit.SECONDS)))
				.trigger(DeltaTrigger.of(triggerMeters,
						new DeltaFunction<Tuple4<Integer, Integer, Double, Long>>() {
							private static final long serialVersionUID = 1L;

							@Override
							public double getDelta(
									Tuple4<Integer, Integer, Double, Long> oldDataPoint,
									Tuple4<Integer, Integer, Double, Long> newDataPoint) {
								return newDataPoint.f2 - oldDataPoint.f2;
							}
						}, carData.getType().createSerializer(env.getConfig())))
				.maxBy(1);

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

		env.execute("CarTopSpeedWindowingExample");
	}
1323872
public static void main(String[] args) throws Exception {
        String input = args[0];
        File outputFile = new File(input.replace(".zip", "") + ".serialized.xz");

        // Get the base name
        FileOutputStream fos = new FileOutputStream(outputFile);
        LZMA2Options options = new LZMA2Options(9);

        XZOutputStream xzo = new XZOutputStream(fos, options);
        ObjectOutputStream oos = new ObjectOutputStream(xzo);

        BundleSerializer ml = new BundleSerializer();
        ml.loadDocuments(input);
        oos.writeObject(ml.toStore);
        oos.flush();
        oos.close();
    }
525071
private Input processRegularFileInput(String input) throws IOException {
    File inputFile = new File(input);
    if (!inputFile.exists()) {
      throw new IOException("Input does not exist: " + input);
    }
    if (pipeFiles) {
      SamReader samReader = SamReaderFactory.makeDefault().open(inputFile);
      return new Input(input, STDIN_FILE_NAME, 
          new SamReaderToSAMFilePump(samReader)); 
    } else {
      return new Input(input, input, null);
    }
  }
1352817
public static void main(String[] args) throws Exception {
		
		for (int i=0; i<args.length; i++) {
			if (args[i].equalsIgnoreCase("-tab")) {  // one response line per each query line, tab-separated
				outputType = outputTypes.TAB;
				token_separator = "\t";
			}
			if (args[i].equalsIgnoreCase("-vert")) { // one response line per token, tab-separated
				outputType = outputTypes.VERT;
			}
			if (args[i].equalsIgnoreCase("-moses")) { // one response line per token, pipe-separated
				field_separator = "|";
				token_separator = " ";
				outputType = outputTypes.MOSES;
			}
			if (args[i].equalsIgnoreCase("-stripped")) mini_tag = true; //remove nonlexical attributes
			if (args[i].equalsIgnoreCase("-features")) features = true; //output training features
			if (args[i].equalsIgnoreCase("-leta")) LETAfeatures = true; //output specific features for LETA semantic frame analysis
			if (args[i].equalsIgnoreCase("-vertinput")) inputType = inputTypes.VERT; //vertical input format as requested by Milos Jakubicek 2012.11.01
			if (args[i].equalsIgnoreCase("-paragraphs")) {
				inputType = inputTypes.PARAGRAPH;
				if (i+1 < args.length && !args[i+1].startsWith("-")) {
					try {
						sentencelengthcap = Integer.parseInt(args[i+1]);
						System.err.printf("Sentence length capped to %d\n", sentencelengthcap);
						i++;
					} catch (Exception e) {
						System.err.printf("Error when parsing command line param '%s %s'\n",args[i], args[i+1]);
						System.err.println(e.getMessage());
					}
				}
			}
			if (args[i].equalsIgnoreCase("-conll-in")) inputType = inputTypes.CONLL; 
			if (args[i].equalsIgnoreCase("-json-in")) inputType = inputTypes.JSON; 
			if (args[i].equalsIgnoreCase("-conll-x")) outputType = outputTypes.CONLL_X;
			if (args[i].equalsIgnoreCase("-xml")) outputType = outputTypes.XML;
			if (args[i].equalsIgnoreCase("-visl-cg")) outputType = outputTypes.VISL_CG;
			if (args[i].equalsIgnoreCase("-lemmatized-text")) outputType = outputTypes.lemmatizedText;
            if (args[i].equalsIgnoreCase("-lowercased-text")) outputType = outputTypes.lowercasedText;
            if (args[i].equalsIgnoreCase("-analyzer")) {
                outputType = outputTypes.analyzerOptions;
                token_separator = "\t";
            }
			if (args[i].equalsIgnoreCase("-saveColumns")) saveColumns = true; //save extra columns from conll input
			if (args[i].equalsIgnoreCase("-unix-line-endings")) eol="\n";
			if (args[i].equalsIgnoreCase("-keep-tags")) keepTags = true;
			if (args[i].equalsIgnoreCase("-output-separators")) outputSeparators = true;
            if (args[i].equalsIgnoreCase("-whitespace-marker")) whitespaceMarker = true;
            if (args[i].equalsIgnoreCase("-allow-empty-lines")) stopOnEmpty = false;
						
			if (args[i].equalsIgnoreCase("-h") || args[i].equalsIgnoreCase("--help") || args[i].equalsIgnoreCase("-?")) {
				System.out.println("LV morphological tagger");
				System.out.println("\nInput formats");
				System.out.println("\tDefault : plain text UTF-8, one sentence per line, terminated by a blank line.");
				System.out.println("\t-paragraphs [lengthcap]: plain text UTF-8, each line will be split in sentences. In output, paragraph borders are noted by an extra blank line. If lengthcap parameter is provided, then sentence length will be limited to that, instead of the default of " + sentencelengthcap);
				System.out.println("\t-vertinput : one line per token, sentences separated by <s></s>. Any XML-style tags are echoed as-is. \n\t\tNB! sentences are retokenized, the number of tokens may be different.");
				System.out.println("\t-conll-in : CONLL shared task data format - one line per token, with tab-delimited columns, sentences separated by blank lines.");
				System.out.println("\t-json-in : one line per sentence, each line contains a single json array of strings-tokens.");
				System.out.println("\nOutput formats");
				System.out.println("\tDefault : JSON. Each sentence is returned as a list of dicts, each dict contains elements 'Word', 'Tag' and 'Lemma'.");
				System.out.println("\t-tab : one response line for each query line; tab-separated lists of word, tag and lemma.");
				System.out.println("\t-vert : one response line for each token; tab-separated lists of word, tag and lemma.");
				System.out.println("\t-moses : one response line for each token; pipe-separated lists of word, tag and lemma.");
				System.out.println("\t-conll-x : CONLL-X shared task data format - one line per token, with tab-delimited columns, sentences separated by blank lines.");
				System.out.println("\t-xml : one xml word per line");
				System.out.println("\t-visl-cg : output format for VISL constraint grammar tool");
				System.out.println("\t-lemmatized-text : output lowercase lemmatized text, each sentence in new row, tokens seperated by single space");
				System.out.println("\t-lowercased-text : output lowercased text, each sentence in new row, tokens seperated by single space");
                System.out.println("\t-analyzer : one response line for each token; word followed by a tab-separated list of undisambiguated morphological tag options");
				System.out.println("\nOther options:");
				System.out.println("\t-stripped : lexical/nonessential parts of the tag are replaced with '-' to reduce sparsity.");
				System.out.println("\t-features : in conll output, include the features that were used for training/tagging.");
				System.out.println("\t-leta : in conll output, include extra features used for semantic frame analysis.");
				System.out.println("\t-saveColumns : save extra columns from conll input.");
				System.out.println("\t-unix-line-endings : use \\n line endings for output even on windows systems");
				System.out.println("\t-keep-tags : preserve lines that start with '<' to enable xml-style metadata");
				System.out.println("\t-output-separators : put <s></s> sentence markup and <p></p> paragraph markup");
				System.out.println("\t-whitespace-marker : put <g /> tags where the tokens did not have whitespace between them");
                System.out.println("\t-allow-empty-lines : do not quit on blank lines input (as per default)");
				System.out.flush();
				System.exit(0);
			}
		}
						
		CMMClassifier<CoreLabel> morphoClassifier = CMMClassifier.getClassifier(morphoClassifierLocation);
			
		PrintStream out = new PrintStream(System.out, true, "UTF8");
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in, "UTF8"));
		
		switch(inputType) {
		case CONLL:
			for (List<CoreLabel> sentence : readCONLL(in)) {
		    	outputSentence(morphoClassifier, out, sentence);
			}
			break;
		default:
		    String s;
		    String sentence = "";
		    while ((s = in.readLine()) != null && (s.length() != 0 || !stopOnEmpty)) {
		    	if (s.startsWith("<") && s.length()>1 && keepTags) {
		    		if (outputType != outputTypes.lemmatizedText && outputType != outputTypes.lowercasedText) out.println(s);
		    		continue;
		    	}
                if (s.length() == 0) continue;
		    	boolean finished = true; // is sentence finished and ready to analyze
		    	if (inputType != inputTypes.VERT) {		    		
		    		sentence = s;
		    	} else {
		    		if (s.startsWith("<") && s.length()>1) out.println(s);
		    		else sentence = sentence + " " + s;
		    		finished = s.startsWith("</s>");
		    	}	    	
		    	if (finished) {
		    		processSentences(morphoClassifier, out, sentence.trim());
			    	sentence = "";
		    	}
		    }
	    	if (inputType != inputTypes.VERT && sentence.length()>0) { //FIXME, not DRY
	    		processSentences(morphoClassifier, out, sentence.trim());
	    	}	    			
		}
		in.close();
		out.close();
	}
254756
public static long copyAndCloseOutput(InputStream input, OutputStream output) throws IOException {
		try (OutputStream outputStream = output) {
			return copy(input, outputStream);
		}
	}
1120947
protected void handleOutput(InputStream stdout) throws IOException {
        byte[] buffer = new byte[4 * 1024];
        int    b;
        while ((b = stdout.read(buffer)) > 0) {
            out.write(buffer, 0, b);
        }
    }
790793
public static void move(String input, String output) throws Exception {
		File inputFile = new File(input);
		File outputFile = new File(output);
		try {
			inputFile.renameTo(outputFile);
		} catch (Exception ex) {
			throw new Exception("Can not mv" + input + " to " + output + ex.getMessage());
		}
	}
1045785
public static void writeToFile(String str, String fileName, Charset charset) throws Exception {
    OutputStreamWriter writer = null;
    if (null == charset) {
      writer = new OutputStreamWriter(new FileOutputStream(fileName));
    } else {
      writer = new OutputStreamWriter(new FileOutputStream(fileName), charset.name());
    }
    writer.write(str);
    writer.close();
  }
1255904
public void toFile(File file) throws Exception {
        PrintWriter out = new PrintWriter(file, "UTF-8");
        try {
            out.write(graph());
        }
        finally {
            Closeables.close(out, true);
        }
    }
65251
public static void writeFile(final Document input, final File output) {
        final StreamResult result = new StreamResult(new StringWriter());

        format(new DOMSource(input), result);

        try {
            new FileWriter(output).write(result.getWriter().toString());
        } catch (final IOException ioEx) {
            LOGGER.error("Problem writing XML to file.", ioEx);
        }
    }
1058122
@Override
    public AbstractPipelineOutput execute(final AbstractPipelineInput input)
            throws DITAOTException {
        if (logger == null) {
            throw new IllegalStateException("Logger not set");
        }
        final FileInfo in = job.getFileInfo(fi -> fi.isInput).iterator().next();
        final File ditaInput = new File(job.tempDirURI.resolve(in.uri));
        if (!ditaInput.exists()) {
            logger.error(MessageUtils.getMessage("DOTJ025E").toString());
            return null;
        }
        final File style = input.getAttribute(ANT_INVOKER_EXT_PARAM_STYLE) != null
                ? new File(input.getAttribute(ANT_INVOKER_EXT_PARAM_STYLE))
                : null;
        final File out = new File(input.getAttribute(ANT_INVOKER_EXT_PARAM_OUTPUT)).getAbsoluteFile();

        final MergeMapParser mapParser = new MergeMapParser();
        mapParser.setLogger(logger);
        mapParser.setJob(job);
        mapParser.setOutput(out);

        final ByteArrayOutputStream midBuffer = new ByteArrayOutputStream();
        try {
            midBuffer.write(XML_HEAD.getBytes(StandardCharsets.UTF_8));
            midBuffer.write(("<dita-merge " + ATTRIBUTE_NAMESPACE_PREFIX_DITAARCHVERSION + "='" + DITA_NAMESPACE + "' "
                    + XMLNS_ATTRIBUTE + ":" + DITA_OT_NS_PREFIX + "='" + DITA_OT_NS + "'>").getBytes(StandardCharsets.UTF_8));
            mapParser.setOutputStream(midBuffer);
            mapParser.read(ditaInput, job.tempDir);
            midBuffer.write("</dita-merge>".getBytes(StandardCharsets.UTF_8));
        } catch (final UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        } catch (final IOException e) {
            throw new DITAOTException("Failed to merge topics: " + e.getMessage(), e);
        }

        final File outputDir = out.getParentFile();
        if (!outputDir.exists() && !outputDir.mkdirs()) {
            logger.error("Failed to create directory " + outputDir.getAbsolutePath());
        }
        try (final OutputStream output = new BufferedOutputStream(new FileOutputStream(out))) {
            if (style != null) {
                final TransformerFactory factory = TransformerFactory.newInstance();
                factory.setURIResolver(CatalogUtils.getCatalogResolver());
                final StreamSource styleSource = new StreamSource(style);
                final Transformer transformer = withLogger(factory.newTransformer(styleSource), logger);
                final StreamSource source = new StreamSource(new ByteArrayInputStream(midBuffer.toByteArray()));
                final StreamResult result = new StreamResult(output);
                transformer.transform(source, result);
            } else {
                output.write(midBuffer.toByteArray());
                output.flush();
            }
        } catch (final RuntimeException e) {
            throw e;
        } catch (final Exception e) {
            throw new DITAOTException("Failed to process merged topics: " + e.getMessage(), e);
        }

        return null;
    }
156040
public static void main(String[] args) throws Exception {
		CWSTagger tag = new CWSTagger("./models/seg.m");	

		RLSeg rlseg = new RLSeg(tag,"./tmpdata/FNLPDATA/all.dict");

		tag.setDictionary(tempdict);

		System.out.println("\n处理文件：");
		String s4 = tag.tagFile("../example-data/data-tag.txt");
		System.out.println(s4);
		String[] toks = s4.split("\\s+");
		int newset = rlseg.update(toks);
		rlseg.close();

		tag.setDictionary(tempdict);

		System.out.println("\n处理文件：");
		String s = tag.tagFile("../example-data/data-tag.txt");
		System.out.println(s);


	}
121513
public void write(String filename) throws Exception {
    data = new TiffOutputStream(input);
    data.setByteOrder(byteOrder);
    try {
      data.create(filename);
      writeHeader();
      writeIfds();
      data.close();
    } catch (Exception ex) {
      ex.printStackTrace();
      if (data != null) {
        data.close();
      }
      throw ex;
    }
  }
96445
public static void main(String[] args) throws Exception {
        java.io.PrintWriter out = new java.io.PrintWriter(System.out);
        new RuntimeWSDL(new File(args[0]), new File(args[1]), args[2])
                .serialize(out);
        out.flush();
    }