Chinese Academy of Sciences participle tool use

Source: Internet
Author: User

The Chinese Academy of Sciences participle tool Java configuration and the inside of the same explanation, the following is the code

 PackageXieru;ImportHello. Hello.clibrary;ImportJava.io.BufferedReader;ImportJava.io.BufferedWriter;ImportJava.io.File;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileReader;ImportJava.io.FileWriter;Importjava.io.IOException;Importjava.io.UnsupportedEncodingException;ImportJava.nio.charset.Charset;ImportJava.util.regex.Pattern;ImportCom.csvreader.CsvReader;ImportCom.csvreader.CsvWriter;Importcom.sun.jna.Library;Importcom.sun.jna.Native; Public classWriteseparatewords { Public InterfaceClibraryextendsLibrary {//defining and initializing static variables for an interfaceClibrary Instance =(clibrary) native.loadlibrary ("E:\\workplace\\hello\\nlpir", clibrary.class); //printf Function Declaration         Public BooleanNlpir_init (byte[] Sdatapath,intencoding,byte[] slicencecode);  PublicString Nlpir_paragraphprocess (String sSrc,intbpostagged);  PublicString Nlpir_getkeywords (String sline,intNmaxkeylimit,Booleanbweightout);  Public voidNlpir_exit (); }     Public Staticstring transstring (String aidstring, String ori_encoding, String new_encoding) {Try {            return NewString (Aidstring.getbytes (ori_encoding), new_encoding); } Catch(unsupportedencodingexception e) {e.printstacktrace (); }        return NULL; }     Public Static voidIt (String infile,string outFile)throwsIOException {File file=NewFile (InFile); FileInputStream fi=Newfileinputstream (file); Csvreader CR=NewCsvreader (FI, ', ', Charset.forname ("GBK")));          Cr.readheaders ();          String[] ReaderS; FileWriter WR=NewFileWriter (OutFile); BufferedWriter BW=NewBufferedWriter (WR);  while(Cr.readrecord ()) {ReaderS=cr.getvalues (); if(Readers[10].equals ("Technology"))){                   for(inti=0;i<readers.length-1;i++) Bw.write ("\" "+readers[i]+" \ "" + ","); Bw.write ("\" "+readers[readers.length-1]+" \ "");              Bw.newline ();          }} bw.flush ();            Bw.close (); }     Public Static voidFenci (String infile,string outFile)throwsioexception{String Argu= ""; String System_charset= "UTF-8"; intCharset_type = 1; //int charset_type = 0; //Call printf Print information        if(!CLibrary.Instance.NLPIR_Init (Argu.getbytes (System_charset), Charset_type,"0". GetBytes (System_charset))) {System.err.println ("Initialization failed!" "); } String FilePath=InFile; File File=NewFile (FilePath); FileInputStream fi=Newfileinputstream (file); Csvreader CR=NewCsvreader (FI, ', ', Charset.forname ("GBK")));        Cr.readheaders ();       String[] ReaderS; FileWriter WR=NewFileWriter (OutFile); BufferedWriter BW=NewBufferedWriter (WR);  while(Cr.readrecord ()) {ReaderS=cr.getvalues (); String nativebytes=NULL; Nativebytes= CLibrary.Instance.NLPIR_ParagraphProcess (Readers[1], 3); Bw.write (readers[0]+ "," + "\" "+nativebytes+" \ "+", "); System.out.println (The result of the word breaker is: "+nativebytes); String Nativebyte= CLibrary.Instance.NLPIR_GetKeyWords (readers[1],10,true);            Bw.write (Nativebyte); System.out.println ("Keyword extraction result is:" +nativebyte);            Bw.newline (); System.out.println ("-----------------------------------");        } bw.flush ();            Bw.close ();            CLibrary.Instance.NLPIR_Exit (); }     Public Static voidMain (string[] args)throwsException {//Writeseparatewords.fenci ("F:/c/zhiweiyaoqiu.csv", "f:/c/fenci.csv");writeseparatewords.it ("F:/c/zhaopinxinxi.csv", "F:/c/it.csv"); }}

Chinese Academy of Sciences participle tool use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.