Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mkyong.rest;
- import javax.ws.rs.GET;
- import javax.ws.rs.Path;
- import javax.ws.rs.Produces;
- import javax.ws.rs.core.MediaType;
- import Summ.summarizers.english.SummarizerEnglishClearNLP;
- @Path("/services")
- public class Service {
- // This method is called if TEXT_PLAIN is request
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String sayPlainTextHello() {
- System.out.println("TEXT_PLAIN");
- SummarizerEnglishClearNLP process = new SummarizerEnglishClearNLP();
- String[] args=new String[] {
- "-inputPath","input_docs"
- ,"-outputPath","output_docs",
- "-maxLength","300",
- "-summaryScorer",
- "cosineAllTFIDF 0.19264679440810492 * cosineQueryTFIDF 0.20319314203268077 * + inverseParaPosition 0.3253659449493686 * + inversePosition 0.2910640501412022 * + inversePositionInPara 0.2670504601993211 * +",
- "-pruningScorer","wordLength 5 > containsBad 0 == +",
- "-pruneMin","2",
- "-flowover",
- "-format","txt",
- "-firstlineQuery",
- "-beam","10"
- };
- args[0]="-inputPath";
- process.processListOfValues(args);
- return "Done !!!";
- }
- // This method is called if XML is request
- @GET
- @Produces(MediaType.TEXT_XML)
- public String sayXMLHello() {
- System.out.println("TEXT_XML");
- SummarizerEnglishClearNLP process = new SummarizerEnglishClearNLP();
- String[] args=new String[] {
- "-inputPath","input_docs"
- ,"-outputPath","output_docs",
- "-maxLength","300",
- "-summaryScorer",
- "cosineAllTFIDF 0.19264679440810492 * cosineQueryTFIDF 0.20319314203268077 * + inverseParaPosition 0.3253659449493686 * + inversePosition 0.2910640501412022 * + inversePositionInPara 0.2670504601993211 * +",
- "-pruningScorer","wordLength 5 > containsBad 0 == +",
- "-pruneMin","2",
- "-flowover",
- "-format","txt",
- "-firstlineQuery",
- "-beam","10"
- };
- args[0]="-inputPath";
- process.processListOfValues(args);
- return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
- }
- // This method is called if HTML is request
- @GET
- @Produces(MediaType.TEXT_HTML)
- public String sayHtmlHello() {
- System.out.println("TEXT_HTML");
- SummarizerEnglishClearNLP process = new SummarizerEnglishClearNLP();
- String[] args=new String[] {
- "-inputPath","C:\\Users\\Rehan\\workspace\\RestServiceForClient\\input_docs"
- ,"-outputPath","C:\\Users\\Rehan\\workspace\\RestServiceForClient\\output_docs",
- "-maxLength","300",
- "-summaryScorer",
- "cosineAllTFIDF 0.19264679440810492 * cosineQueryTFIDF 0.20319314203268077 * + inverseParaPosition 0.3253659449493686 * + inversePosition 0.2910640501412022 * + inversePositionInPara 0.2670504601993211 * +",
- "-pruningScorer","wordLength 5 > containsBad 0 == +",
- "-pruneMin","2",
- "-flowover",
- "-format","txt",
- "-firstlineQuery",
- "-beam","10"
- };
- args[0]="-inputPath";
- process.processListOfValues(args);
- return "<html> " + "<title>" + "Hello Jersey" + "</title>"
- + "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement