protected static Triple[] createTriple(String[] tags, String[] lemmas, String[] feats) { Triple[] triples = new Triple[tags.length]; for (int i = 0; i < tags.length; i++) { triples[i] = new Triple(tags[i], lemmas[i], feats[i]); } return triples; }
private static String toString(String word, Triple t) { StringBuilder sb = new StringBuilder(); sb.append(word).append(HT).append(t.getLemma()).append(HT) .append(t.getClazz()); if (t.getFeats() != null && t.getFeats().length() > 0) { sb.append("#").append(t.getFeats()); } sb.append(NL); return sb.toString(); } }
public String getLemma(String word, String tag) { if (caseSensitive) { List<Triple> triples = dictionary.get(word); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { return t.getLemma(); } } } else { List<Triple> triples = dictionary.get(word.toLowerCase()); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { return t.getLemma(); } } } return null; }
private static String[] getTags(List<Triple> triples) { if (triples == null) { return null; } String[] tags = new String[triples.size()]; int i = 0; for (Triple t : triples) { tags[i++] = t.getClazz(); } return tags; }
private static String[] getFeats(List<Triple> triples) { if (triples == null) return null; String[] feats = new String[triples.size()]; int i = 0; for (Triple t : triples) { feats[i++] = t.getFeats(); } return feats; }
public int compareTo(Triple o) { return this.lemma.compareTo(o.getLemma()); } }
public String getLemma(String word, String tag) { if (caseSensitive) { List<Triple> triples = dictionary.get(word); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { return t.getLemma(); } } } else { List<Triple> triples = dictionary.get(word.toLowerCase()); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { return t.getLemma(); } } } return null; }
private static String[] getTags(List<Triple> triples) { if (triples == null) { return null; } String[] tags = new String[triples.size()]; int i = 0; for (Triple t : triples) { tags[i++] = t.getClazz(); } return tags; }
private static String[] getFeats(List<Triple> triples) { if (triples == null) return null; String[] feats = new String[triples.size()]; int i = 0; for (Triple t : triples) { feats[i++] = t.getFeats(); } return feats; }
public int compareTo(Triple o) { return this.lemma.compareTo(o.getLemma()); } }
private static String toString(String word, Triple t) { StringBuilder sb = new StringBuilder(); sb.append(word).append(HT).append(t.getLemma()).append(HT) .append(t.getClazz()); if (t.getFeats() != null && t.getFeats().length() > 0) { sb.append("#").append(t.getFeats()); } sb.append(NL); return sb.toString(); } }
public String[] getFeatures(String word, String tag) { List<String> feats = new ArrayList<String>(); if (caseSensitive) { List<Triple> triples = dictionary.get(word); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { feats.add(t.getFeats()); } } } else { List<Triple> triples = dictionary.get(word.toLowerCase()); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { feats.add(t.getFeats()); } } } if (feats.size() > 0) { return feats.toArray(new String[feats.size()]); } return null; }
public WordTag next() { if(innerTriple == null || !innerTriple.hasNext()) { word = inner.next(); innerTriple = dictionary.get(word).iterator(); } Triple val = innerTriple.next(); return new WordTag(word, val.getClazz()); }
public Entry next() { String word = iterator.next(); List<Triple> triples = dictionary.get(word); Attributes tagAttribute = new Attributes(); String[] tags = new String[triples.size()]; String[] lemmas = new String[triples.size()]; String[] feats = new String[triples.size()]; int i = 0; for (Triple t : triples) { tags[i] = t.getClazz(); lemmas[i] = t.getLemma(); feats[i++] = t.getFeats(); } tagAttribute.setValue(ATTR_TAGS, tagsToString(tags)); tagAttribute.setValue(ATTR_LEMMAS, tagsToString(lemmas)); tagAttribute.setValue(ATTR_FEATS, tagsToString(feats)); return new Entry(new StringList(word), tagAttribute); }
public String[] getFeatures(String word, String tag) { List<String> feats = new ArrayList<String>(); if (caseSensitive) { List<Triple> triples = dictionary.get(word); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { feats.add(t.getFeats()); } } } else { List<Triple> triples = dictionary.get(word.toLowerCase()); if (triples == null) return null; for (Triple t : triples) { if (tag.equals(t.getClazz())) { feats.add(t.getFeats()); } } } if (feats.size() > 0) { return feats.toArray(new String[feats.size()]); } return null; }