/** char offsets of mention **/ public Pair<Integer,Integer> charOffsets() { int beginCharOffset = this.entityMentionCoreMap.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class); int endCharOffset = this.entityMentionCoreMap.get(CoreAnnotations.CharacterOffsetEndAnnotation.class); return new Pair<>(beginCharOffset,endCharOffset); }
/** * Convert a CoreMap representing a sentence into a string, by simply joining them with spaces. * @param sentence The sentence to stringify. * @return A string representation of the sentence, tokenized by a single space. */ public static String toString(CoreMap sentence) { return toString(sentence.get(CoreAnnotations.TokensAnnotation.class)); }
protected void readRightParen() { // System.out.println("Read right."); readWhiteSpace(); char ch = read(); if (!isRightParen(ch)) throw new ParserException("Expected right paren!"); }
public EmpiricalNERPriorBIO(String backgroundSymbol, Index<String> classIndex, Index<String> tagIndex, List<IN> doc, Pair<double[][], double[][]> matrices, SeqClassifierFlags flags) { super(backgroundSymbol, classIndex, tagIndex, doc); entityMatrix = matrices.first(); subEntityMatrix = matrices.second(); this.flags = flags; ORGIndex = tagIndex.indexOf("ORG"); LOCIndex = tagIndex.indexOf("LOC"); }
public static TwoDimensionalSet<String, String> getBinaryMatrixNames(List<TwoDimensionalMap<String, String, SimpleMatrix>> maps) { TwoDimensionalSet<String, String> matrixNames = new TwoDimensionalSet<>(); for (TwoDimensionalMap<String, String, SimpleMatrix> map : maps) { for (TwoDimensionalMap.Entry<String, String, SimpleMatrix> entry : map) { matrixNames.add(entry.getFirstKey(), entry.getSecondKey()); } } return matrixNames; }
public Pair<String, String> indexToBinaryTransform(int pos) { if (pos < numBinaryMatrices * binaryTransformSize) { for (TwoDimensionalMap.Entry<String, String, SimpleMatrix> entry : binaryTransform) { if (binaryTransformSize < pos) { pos -= binaryTransformSize; } else { return Pair.makePair(entry.getFirstKey(), entry.getSecondKey()); } } } return null; }
@Override public boolean test(T in) { if (exact) { return in.getInterval().equals(target); } else { return in.getInterval().contains(target); } } }
public void setOptions(String options) { Properties prop = StringUtils.stringToProperties(options); tokenizeNLs = PropertiesUtils.getBool(prop, "tokenizeNLs", tokenizeNLs); } }
/** * Populate with the given command-line arguments all static options in all * classes in the current classpath. * Note that this may take a while if the classpath is large. * * @param args The command-line arguments to use to fill options. */ public static void fillOptions(String... args) { fillOptions(StringUtils.argsToProperties(args), StringUtils.EMPTY_STRING_ARRAY); }
/** * Adds all the keys in the given TwoDimensionalMap. Returns true iff at least one key is added. */ public boolean addAllKeys(TwoDimensionalMap<? extends K1, ? extends K2, ?> map) { boolean result = false; for (TwoDimensionalMap.Entry<? extends K1, ? extends K2, ?> entry : map) { if (add(entry.getFirstKey(), entry.getSecondKey())) { result = true; } } return result; }
public String toStringNoScore(Index<String> index) { if (cached == null) { cached = '\"' + StringUtils.escapeString(index.get(parent), charsToEscape, '\\') + "\" -> \"" + StringUtils.escapeString(index.get(child), charsToEscape, '\\'); } return cached; }
/** * Creates a "delta copy" of this Map, where only the differences * from the original Map are represented. (This typically assumes * that this map will no longer be changed.) */ public CollectionValuedMap<K, V> deltaCopy() { Map<K,Collection<V>> deltaMap = new DeltaMap<>(this.map); return new CollectionValuedMap<>(null, cf, true, deltaMap); }
public static <T extends HasInterval<E>, E extends Comparable<E>> List<T> getNonOverlapping( List<? extends T> items) { Function<T,Interval<E>> toIntervalFunc = in -> in.getInterval(); return getNonOverlapping(items, toIntervalFunc); }
/** * Creates a new empty TwoDimensionalCollectionValuedMap which uses a HashMap as the * underlying Map, and HashSets as the Collections in each mapping. Does not * treat Collections as immutable. */ public TwoDimensionalCollectionValuedMap() { this(MapFactory.<K2,Collection<V>>hashMapFactory(), CollectionFactory.<V>hashSetFactory(), false); }
public static <E extends FuzzyComparable<E>> FuzzyInterval<E> toValidInterval(E a, E b, int flags) { int comp = a.compareTo(b); if (comp <= 0) { return new FuzzyInterval<>(a, b, flags); } else { return new FuzzyInterval<>(b, a, flags); } }
/** char offsets of mention **/ public Pair<Integer,Integer> charOffsets() { int beginCharOffset = this.sentenceCoreMap.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class); int endCharOffset = this.sentenceCoreMap.get(CoreAnnotations.CharacterOffsetEndAnnotation.class); return new Pair<>(beginCharOffset,endCharOffset); }
@Override public void setOptions(String options) { Properties prop = StringUtils.stringToProperties(options); tokenizeNLs = PropertiesUtils.getBool(prop, "tokenizeNLs", tokenizeNLs); }
public static <E extends FuzzyComparable<E>> FuzzyInterval<E> toInterval(E a, E b, int flags) { int comp = a.compareTo(b); if (comp <= 0) { return new FuzzyInterval<>(a, b, flags); } else { return null; } }
/** char offsets of quote **/ public Pair<Integer,Integer> quoteCharOffsets() { int beginCharOffset = this.quoteCoreMap.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class); int endCharOffset = this.quoteCoreMap.get(CoreAnnotations.CharacterOffsetEndAnnotation.class); return new Pair<>(beginCharOffset,endCharOffset); }