/** * This method is used when constructing the dictionary data object. * Constructs an map with an empty sub-map for every part of speech. * Subclasses may override to change map character * * @param <K> * the type of the keys for the sub-maps * @param <V> * the type of the values for the sub-maps * @return a map with an empty sub-map for every part of speech. * @since JWI 2.2.0 */ protected <K,V> Map<POS, Map<K,V>> makePOSMap(){ Map<POS, Map<K,V>> result = new HashMap<POS, Map<K,V>>(POS.values().length); for(POS pos : POS.values()) result.put(pos, this.<K,V>makeMap(4096, null)); return result; }
/** * Get a list of possible stems. Assume we are looking up a noun. */ public static List<String> getStems(String word, String posTag, IDictionary iDictionary) { POS pos = POS.getPartOfSpeech(posTag.charAt(0)); if(pos == null) { return new ArrayList<String>(); } WordnetStemmer wordnetStemmer = new WordnetStemmer(iDictionary); List<String> stems = wordnetStemmer.findStems(word, pos); return stems; }
public ArrayList<IWord> getIWords(String st, POS pos_) { List<String> stems = getStemsList(st, pos_); ArrayList<IWord> iwds = new ArrayList<IWord>(); for(String s: stems){ //System.out.println(s); for (POS pos : POS.values()) { if(pos_!=null && !pos.equals(pos_)) continue; IIndexWord idxWord = dict.getIndexWord(s, pos); //System.out.println(idxWord); if(idxWord==null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for(IWordID iw : senses) { //System.out.println(iw); iwds.add(dict.getWord(iw)); } } } return iwds; }
&& POS.getPartOfSpeech(t.getPos().charAt(0)) != null) { POS pos = POS.getPartOfSpeech(t.getPos().charAt(0)); List<String> stems = stemmer.findStems(t.getCoveredText(), pos); for (POS pos : POS.values()) { List<String> stems = stemmer.findStems( t.getCoveredText(), pos);
end = key.indexOf(':', begin); int ss_type = Integer.parseInt(key.substring(begin, end)); POS pos = POS.getPartOfSpeech(ss_type); boolean isAdjSat = POS.isAdjectiveSatellite(ss_type);
public String toString() { return "EID-" + surfaceForm + "-" + pos.getTag(); }
/** * Calculates similarity between word1 and word2 * TODO: determine catalog of POS values for POS tags of word1 and word2 * * @param arg1 1st component (word + POS tag) * @param arg2 2nd component * @return similarity score between words plus a "reason" * @throws IllegalArgumentException * @throws NotImplementedException */ public MetricResponse compare(MetricWord arg1, MetricWord arg2) throws IllegalArgumentException, NotImplementedException { String pos1 = ( null == arg1.pos ) ? null : arg1.pos.name(); String pos2 = ( null == arg2.pos ) ? null : arg2.pos.name(); double score = this.parascore(arg1.word, pos1, arg2.word, pos2); return new MetricResponse(score, NAME); //return null; }
public ArrayList<IWord> getIWords(String st, POS pos_) { List<String> stems = getStemsList(st, pos_); ArrayList<IWord> iwds = new ArrayList<IWord>(); for (String s : stems) { // System.out.println(s); for (POS pos : POS.values()) { if (pos_ != null && !pos.equals(pos_)) continue; IIndexWord idxWord = dict.getIndexWord(s, pos); // System.out.println(idxWord); if (idxWord == null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for (IWordID iw : senses) { // System.out.println(iw); iwds.add(dict.getWord(iw)); } } } return iwds; }
public String toString() { return "XID-" + lemma + "-" + pos.getTag(); }
/** * Calculates similarity between word1 and word2 TODO: determine catalog of * POS values for POS tags of word1 and word2 * * @param arg1 * 1st component (word + POS tag) * @param arg2 * 2nd component * @return similarity score between words plus a "reason" * @throws IllegalArgumentException * @throws NotImplementedException */ public MetricResponse compare(MetricWord arg1, MetricWord arg2) throws IllegalArgumentException, NotImplementedException { String pos1 = (null == arg1.pos) ? null : arg1.pos.name(); String pos2 = (null == arg2.pos) ? null : arg2.pos.name(); double score = this.parascore(arg1.word, pos1, arg2.word, pos2); return new MetricResponse(score, NAME); // return null; }
ArrayList<ISynset> synsets2 = wrap.getAllSynset(w2, p2); if (p1 != null && p2 != null && !p1.equals(p2)) return 0.; double min2 = 100; double sum = 100; for (POS pos : POS.values()) { min1 = 100; min2 = 100; if (pos.equals(POS.NOUN)) continue; for (ISynset is : synsets1) { if (!pos.equals(is.getPOS())) continue; double d = getLCS(is); if (!pos.equals(is.getPOS())) continue;
private boolean match(ISynset left, ArrayList<ISynset> synsets2) { for (ISynset is : synsets2) { if (is.equals(left) && is.getPOS().equals(left.getPOS())) return true; } return false; }
public ArrayList<ISynset> getAllSynset(String word) { ArrayList<ISynset> lis = new ArrayList<ISynset>(); for (POS p : POS.values()) { lis.addAll(getAllSynset(word, p)); // System.out.println(p+" "+Arrays.toString(lis.toArray())); } return lis; }
/** * Get a list of possible stems. Assume we are looking up a noun. */ public static List<String> getStems(String word, String posTag, IDictionary iDictionary) { POS pos = POS.getPartOfSpeech(posTag.charAt(0)); if(pos == null) { return new ArrayList<String>(); } WordnetStemmer wordnetStemmer = new WordnetStemmer(iDictionary); List<String> stems = wordnetStemmer.findStems(word, pos); return stems; }
public String toString() { StringBuilder sb = new StringBuilder(14); sb.append(synsetIDPrefix); sb.append(Synset.zeroFillOffset(offset)); sb.append('-'); sb.append(Character.toUpperCase(pos.getTag())); return sb.toString(); }
ArrayList<ISynset> synsets2 = wrap.getAllSynset(w2, p2); if (p1 != null && p2 != null && !p1.equals(p2)) return 0.; for (POS pos : POS.values()) { min1 = 100; min2 = 100; if (pos.equals(POS.NOUN)) continue; for (ISynset is : synsets1) { if (!pos.equals(is.getPOS())) continue; double d = getLCS(is); if (d < min1) min1 = d; if (!pos.equals(is.getPOS())) continue;
private boolean match(ISynset left, ArrayList<ISynset> synsets2) { for (ISynset is : synsets2) { // System.out.println(left+" "+is); if (is.equals(left) && is.getPOS().equals(left.getPOS())) return true; } return false; }
public Set<String> getWordNetStems(String word) { Set<String> stems = new HashSet<String>(); for (POS pos : POS.values()) stems.addAll(wnStemmer.findStems(word, pos)); return stems; } }