/** * Retrieves the string covered by the current span of the specified text. * * @param text * * @return the substring covered by the current span */ public CharSequence getCoveredText(CharSequence text) { if (getEnd() > text.length()) { throw new IllegalArgumentException("The span " + toString() + " is outside the given text which has length " + text.length() + "!"); } return text.subSequence(getStart(), getEnd()); }
/** * Initializes the current instance. * * @param text the text which contains the tokens. * @param tokenSpans the spans which mark the begin and end of the tokens. */ public TokenSample(String text, Span[] tokenSpans) { Objects.requireNonNull(tokenSpans, "tokenSpans must not be null"); this.text = Objects.requireNonNull(text, "text must not be null"); this.tokenSpans = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(tokenSpans))); for (Span tokenSpan : tokenSpans) { if (tokenSpan.getStart() < 0 || tokenSpan.getStart() > text.length() || tokenSpan.getEnd() > text.length() || tokenSpan.getEnd() < 0) { throw new IllegalArgumentException("Span " + tokenSpan.toString() + " is out of bounds, text length: " + text.length() + "!"); } } }
for(Span s: nameSpans){ String a = s.toString().replace("[", "").replace(")", ""); String[] b = a.split("\\s"); String[] c = b[0].split("\\.."); int first = Integer.parseInt(c[0]); int second = Integer.parseInt(c[1]); String[] word = input.split("\\s"); int n; for(n=first;n<second;n++){ names.add(word[n]); System.out.println(word[n]); } }
/** * Retrieves the string covered by the current span of the specified text. * * @param text * * @return the substring covered by the current span */ public CharSequence getCoveredText(CharSequence text) { if (getEnd() > text.length()) { throw new IllegalArgumentException("The span " + toString() + " is outside the given text which has length " + text.length() + "!"); } return text.subSequence(getStart(), getEnd()); }
/** * Retrieves the string covered by the current span of the specified text. * * @param text * * @return the substring covered by the current span */ public CharSequence getCoveredText(CharSequence text) { if (getEnd() > text.length()) { throw new IllegalArgumentException("The span " + toString() + " is outside the given text which has length " + text.length() + "!"); } return text.subSequence(getStart(), getEnd()); }
/** * Initializes the current instance. * * @param text the text which contains the tokens. * @param tokenSpans the spans which mark the begin and end of the tokens. */ public TokenSample(String text, Span[] tokenSpans) { Objects.requireNonNull(tokenSpans, "tokenSpans must not be null"); this.text = Objects.requireNonNull(text, "text must not be null"); this.tokenSpans = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(tokenSpans))); for (Span tokenSpan : tokenSpans) { if (tokenSpan.getStart() < 0 || tokenSpan.getStart() > text.length() || tokenSpan.getEnd() > text.length() || tokenSpan.getEnd() < 0) { throw new IllegalArgumentException("Span " + tokenSpan.toString() + " is out of bounds, text length: " + text.length() + "!"); } } }
/** * Initializes the current instance. * * @param text the text which contains the tokens. * @param tokenSpans the spans which mark the begin and end of the tokens. */ public TokenSample(String text, Span[] tokenSpans) { Objects.requireNonNull(tokenSpans, "tokenSpans must not be null"); this.text = Objects.requireNonNull(text, "text must not be null"); this.tokenSpans = Collections.unmodifiableList(new ArrayList<>(Arrays.asList(tokenSpans))); for (Span tokenSpan : tokenSpans) { if (tokenSpan.getStart() < 0 || tokenSpan.getStart() > text.length() || tokenSpan.getEnd() > text.length() || tokenSpan.getEnd() < 0) { throw new IllegalArgumentException("Span " + tokenSpan.toString() + " is out of bounds, text length: " + text.length() + "!"); } } }
for(Span s: nameSpans) System.out.print(s.toString()); System.out.print(" "); for(int index = s.getStart();index < s.getEnd();index++)
System.out.println(s.toString()); for(int i = s.getStart(); i < s.getEnd(); i++) {
log.debug("Span: " + nameSpans[i].toString()); log.debug("Covered text is: " + tokens[nameSpans[i].getStart()]); log.debug("Probability is: " + spanProbs[i]);
final String span = nameSpans[i].toString();