public List<CoreMap> getAPIElementSentences(boolean parse) { List<CoreMap> sentences = section.sentences; // getAllSentences(parse); List<CoreMap> apiSentences = new ArrayList<CoreMap>(); String formattedAPI = apiElement .getAPIElementName() .replaceAll("\\(", "") .replaceAll("\\)", "") .replaceAll("\\.", "-") .toLowerCase(); if (sentences == null) System.out.println("Warning"); for (CoreMap sent : sentences) { if (sent.toString().toLowerCase().indexOf("clt_" + formattedAPI) != -1) apiSentences.add(sent); } if (apiSentences.isEmpty()) System.out.println( "WARNGING: In getAPIElementSentences " + apiElement.getAPIElementName() + "," + section.getSubTitle()); return apiSentences; }
public void saveToFile(String saveFilePath) { try { CSVWriter writer = new CSVWriter(new FileWriter(saveFilePath, true)); writer.writeNext( new String[] { section.getSubTitle(), apiElement.getAPIElementName(), Boolean.toString(label) }); writer.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private String modifyAPIElementText(String html) { Document doc = Jsoup.parse(html); Elements clts = doc.select("clt[api=" + apiElement.getAPIElementName() + "]"); for (Element clt : clts) { if (clt.text().equals(clt.attr("api"))) clt.text("clt_" + clt.attr("api")); else { String[] content = clt.text().split("\\."); System.out.println( clt.text() + "=>" + "clt_" + clt.attr("api") + "_" + content[content.length - 1]); clt.text("clt_" + clt.attr("api") + "_" + content[content.length - 1]); } } return doc.html(); }