Advertisement
Guest User

Untitled

a guest
May 25th, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. package com.mkyong.rest;
  2. import javax.ws.rs.GET;
  3. import javax.ws.rs.Path;
  4. import javax.ws.rs.Produces;
  5. import javax.ws.rs.core.MediaType;
  6.  
  7. import Summ.summarizers.english.SummarizerEnglishClearNLP;
  8.  
  9. @Path("/services")
  10. public class Service {
  11.  
  12. // This method is called if TEXT_PLAIN is request
  13. @GET
  14. @Produces(MediaType.TEXT_PLAIN)
  15. public String sayPlainTextHello() {
  16. System.out.println("TEXT_PLAIN");
  17.  
  18. SummarizerEnglishClearNLP process = new SummarizerEnglishClearNLP();
  19. String[] args=new String[] {
  20. "-inputPath","input_docs"
  21. ,"-outputPath","output_docs",
  22. "-maxLength","300",
  23. "-summaryScorer",
  24. "cosineAllTFIDF 0.19264679440810492 * cosineQueryTFIDF 0.20319314203268077 * + inverseParaPosition 0.3253659449493686 * + inversePosition 0.2910640501412022 * + inversePositionInPara 0.2670504601993211 * +",
  25. "-pruningScorer","wordLength 5 > containsBad 0 == +",
  26. "-pruneMin","2",
  27. "-flowover",
  28. "-format","txt",
  29. "-firstlineQuery",
  30. "-beam","10"
  31. };
  32. args[0]="-inputPath";
  33.  
  34.  
  35. process.processListOfValues(args);
  36. return "Done !!!";
  37. }
  38.  
  39. // This method is called if XML is request
  40. @GET
  41. @Produces(MediaType.TEXT_XML)
  42. public String sayXMLHello() {
  43. System.out.println("TEXT_XML");
  44. SummarizerEnglishClearNLP process = new SummarizerEnglishClearNLP();
  45. String[] args=new String[] {
  46. "-inputPath","input_docs"
  47. ,"-outputPath","output_docs",
  48. "-maxLength","300",
  49. "-summaryScorer",
  50. "cosineAllTFIDF 0.19264679440810492 * cosineQueryTFIDF 0.20319314203268077 * + inverseParaPosition 0.3253659449493686 * + inversePosition 0.2910640501412022 * + inversePositionInPara 0.2670504601993211 * +",
  51. "-pruningScorer","wordLength 5 > containsBad 0 == +",
  52. "-pruneMin","2",
  53. "-flowover",
  54. "-format","txt",
  55. "-firstlineQuery",
  56. "-beam","10"
  57. };
  58. args[0]="-inputPath";
  59.  
  60.  
  61. process.processListOfValues(args);
  62.  
  63. return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
  64. }
  65.  
  66. // This method is called if HTML is request
  67. @GET
  68. @Produces(MediaType.TEXT_HTML)
  69. public String sayHtmlHello() {
  70.  
  71. System.out.println("TEXT_HTML");
  72. SummarizerEnglishClearNLP process = new SummarizerEnglishClearNLP();
  73. String[] args=new String[] {
  74. "-inputPath","C:\\Users\\Rehan\\workspace\\RestServiceForClient\\input_docs"
  75. ,"-outputPath","C:\\Users\\Rehan\\workspace\\RestServiceForClient\\output_docs",
  76. "-maxLength","300",
  77. "-summaryScorer",
  78. "cosineAllTFIDF 0.19264679440810492 * cosineQueryTFIDF 0.20319314203268077 * + inverseParaPosition 0.3253659449493686 * + inversePosition 0.2910640501412022 * + inversePositionInPara 0.2670504601993211 * +",
  79. "-pruningScorer","wordLength 5 > containsBad 0 == +",
  80. "-pruneMin","2",
  81. "-flowover",
  82. "-format","txt",
  83. "-firstlineQuery",
  84. "-beam","10"
  85. };
  86. args[0]="-inputPath";
  87.  
  88.  
  89. process.processListOfValues(args);
  90.  
  91.  
  92. return "<html> " + "<title>" + "Hello Jersey" + "</title>"
  93. + "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement