List of usage examples for org.apache.commons.lang3 StringUtils substringsBetween
public static String[] substringsBetween(final String str, final String open, final String close)
Searches a String for substrings delimited by a start and end tag, returning all matching substrings in an array.
A null input String returns null .
From source file:opennlp.tools.parse_thicket.opinion_processor.AbstractEngineRunner.java
public void processJSONfileWithReviews() { List<String[]> report = new ArrayList<String[]>(); report.add(new String[] { "text", "phrases of potential interest list", }); String content = null;/*from w w w . ja v a 2s .c o m*/ try { content = FileUtils.readFileToString(new File(reviewSource)); } catch (IOException e) { e.printStackTrace(); } String[] texts = StringUtils.substringsBetween(content, "reviewText\": \"", "\", \"overall"); for (String text : texts) { EntityExtractionResult result = neExtractor.extractEntities(text); report.add(new String[] { text }); // report.add((String[])result.extractedNERWords.toArray(new // String[0])); // report.add((String[])result.extractedSentimentPhrases.toArray(new // String[0])); List<String> stringPhrases = new ArrayList<String>(), nodePhrases = new ArrayList<String>(); for (List<ParseTreeNode> chList : result.extractedSentimentPhrases) { String buf = "", nodeBuf = ""; for (ParseTreeNode ch : chList) { buf += ch.getWord() + " "; nodeBuf += ch.toString() + " "; } stringPhrases.add(buf.trim()); nodePhrases.add(nodeBuf.trim()); } report.add((String[]) stringPhrases.toArray(new String[0])); report.add((String[]) nodePhrases.toArray(new String[0])); report.add(new String[] { "-----------------------------" }); ProfileReaderWriter.writeReport(report, "nameEntitiesTopicsOfInterestExtracted.csv"); } }
From source file:org.aliuge.crawler.extractor.selector.action.file.DownLoadFileAction.java
License:asdf
/** * /*from w w w.java 2s .co m*/ * @param dir * @param md5File */ public DownLoadFileAction(String dir, boolean md5File) { if (!dir.contains("{")) { this.dir = new File(dir); if (!this.dir.exists()) { this.dir.mkdir(); } } else { this.dynamicPath = Lists.newArrayList(StringUtils.substringsBetween(dir, "{", "}")); String ss[] = StringUtils.split(dir, "/"); for (String s : ss) { if (!s.contains("{")) { this.dynamicPath.add(0, s); } } } this.md5File = md5File; }
From source file:org.aliuge.crawler.extractor.selector.action.file.DownLoadFileAction.java
License:asdf
/** * //from ww w . j a va 2s . com * @param dir * @param md5File * @param asynchronous */ public DownLoadFileAction(String dir, boolean md5File, boolean asynchronous) { super(); if (!dir.contains("{")) { this.dir = new File(dir); if (!this.dir.exists()) { this.dir.mkdir(); } } else { this.dynamicPath = Lists.newArrayList(StringUtils.substringsBetween(dir, "{", "}")); String ss[] = StringUtils.split(dir, "/"); for (String s : ss) { if (!s.contains("{")) { this.dynamicPath.add(0, s); } } } this.md5File = md5File; this.asynchronous = asynchronous; }
From source file:org.aliuge.crawler.extractor.selector.action.file.DownLoadImageResizeAction.java
/** * /*from ww w. j a va 2 s. c o m*/ * @param dir * @param md5File * @param asynchronous * @param blockSize * @param w * @param h * @param quality * @param deleteOldFile */ public DownLoadImageResizeAction(String dir, boolean md5File, boolean asynchronous, long blockSize, int w, int h, Float quality, boolean deleteOldFile) { if (!dir.contains("{")) { this.dir = new File(dir); if (!this.dir.exists()) { this.dir.mkdir(); } } else { this.dynamicPath = Lists.newArrayList(StringUtils.substringsBetween(dir, "{", "}")); // ?? String ss[] = StringUtils.split(dir, "/"); for (String s : ss) { if (!s.contains("{")) { this.dynamicPath.add(0, s); } } } this.md5File = md5File; this.asynchronous = asynchronous; this.blockSize = blockSize; this.w = w; this.h = h; this.quality = quality; this.deleteOldFile = deleteOldFile; }
From source file:org.aliuge.crawler.extractor.selector.action.file.DownLoadImageResizeAction.java
/** * /*from ww w . ja va 2 s. c o m*/ * @param dir * @param md5File */ public DownLoadImageResizeAction(String dir, boolean md5File) { super(); if (!dir.contains("{")) { this.dir = new File(dir); if (!this.dir.exists()) { this.dir.mkdir(); } } else { this.dynamicPath = Lists.newArrayList(StringUtils.substringsBetween(dir, "{", "}")); String ss[] = StringUtils.split(dir, "/"); for (String s : ss) { if (!s.contains("{")) { this.dynamicPath.add(0, s); } } } this.md5File = md5File; }
From source file:org.aliuge.crawler.extractor.selector.action.file.DownLoadImageResizeAction.java
/** * // www . j a va 2 s . c o m * @param dir * @param md5File * @param asynchronous */ public DownLoadImageResizeAction(String dir, boolean md5File, boolean asynchronous) { super(); if (!dir.contains("{")) { this.dir = new File(dir); if (!this.dir.exists()) { this.dir.mkdir(); } } else { this.dynamicPath = Lists.newArrayList(StringUtils.substringsBetween(dir, "{", "}")); String ss[] = StringUtils.split(dir, "/"); for (String s : ss) { if (!s.contains("{")) { this.dynamicPath.add(0, s); } } } this.md5File = md5File; this.asynchronous = asynchronous; }
From source file:org.aliuge.crawler.extractor.selector.action.string.StringBetweenAction.java
/** * ??<br>// ww w .ja va 2s . c om * tt,t<br> * t,xt,x<br> * t,x,#t,x# */ @Override public String doAction(String content) { if (StringUtils.isNotBlank(content)) { String[] ss = StringUtils.split(exp, ","); if (ss.length == 1) { return StringUtils.substringBetween(content, ss[0]); } else if (ss.length == 2) { return StringUtils.substringBetween(content, ss[0], ss[1]); } else if (ss.length == 3) { String[] contents = StringUtils.substringsBetween(content, ss[0], ss[1]); if (null != contents) { StringBuilder sb = new StringBuilder(); for (String s : contents) { sb.append(s).append(ss[2]); } return sb.substring(0, sb.length() - 1); } } else { return content; } } return ""; }
From source file:org.bigtester.ate.model.data.AbstractRunTimeDataHolder.java
/** * Parses the left right boundry data.// w w w . j a v a 2 s. c om * * @throws RuntimeDataException the runtime data exception */ protected void parseLeftRightBoundryData(int index) throws RuntimeDataException { String str = getPage().getPageHtmlSource(); String[] values = StringUtils.substringsBetween(str, getPageHtmlLeftBoundry(), getPageHtmlRightBoundry()); if (null == values) { throw new RuntimeDataException(ExceptionMessage.MSG_RUNTIMEDATA_NOTFOUND, ExceptionErrorCode.RUNTIMEDATA_NOTFOUND); } if (values.length < index + 1 || -1 == index) { index = values.length - 1; } String setVal = values[index]; if (null == setVal) { throw GlobalUtils.createInternalError("parseLeftRightBoundryData"); } else { setStrDataValue(setVal); } }
From source file:org.codice.ddf.commands.solr.RestoreCommandTest.java
private String getRequestStatus(String consoleOutput) { return StringUtils.trim(StringUtils .substringsBetween(ASCII_COLOR_CODES_REGEX.matcher(consoleOutput).replaceAll(""), "[", "]")[1]); }
From source file:org.codice.ddf.commands.solr.RestoreCommandTest.java
private String getBackupName(String consoleOutput) { return StringUtils.trim(StringUtils .substringsBetween(ASCII_COLOR_CODES_REGEX.matcher(consoleOutput).replaceAll(""), "[", "]")[2]); }