/** * Constructor * * @param collection */ public THashSet(Collection<? extends E> collection) { this(collection.size()); addAll(collection); }
/** * Creates a new <code>THashSet</code> instance containing the * elements of <tt>collection</tt>. * * @param collection a <code>Collection</code> value * @param strategy used to compute hash codes and to compare objects. */ public THashSet(Collection collection, TObjectHashingStrategy strategy) { this(collection.size(), strategy); addAll(collection); }
/** * Constructor * * @param collection */ public THashSet(Collection<? extends E> collection) { this(collection.size()); addAll(collection); }
/** * Creates a new <code>THashSet</code> instance containing the * elements of <tt>collection</tt>. * * @param collection a <code>Collection</code> value */ public THashSet(Collection collection) { this(collection.size()); addAll(collection); }
static Operation getSumSetOperation() { final Set theirSet = new HashSet(dataset.size()); final THashSet ourSet = new THashSet(dataset.size()); theirSet.addAll(dataset); ourSet.addAll(dataset); final TObjectProcedure proc = new TObjectProcedure() { int sum = 0; public boolean execute(Object o) { sum += ((Integer)o).intValue(); return true; } }; return new Operation() { public void theirs() { int sum = 0; for (Iterator i = theirSet.iterator(); i.hasNext();) { sum += ((Integer)i.next()).intValue(); } } public void ours() { ourSet.forEach(proc); } public String toString() { return "sums a " + theirSet.size() + " element Set of Integer objects. Their approach uses Iterator.hasNext()/next(); ours uses THashSet.forEach(TObjectProcedure)"; } public int getIterationCount() { return 10; } }; }
public static Set<String> getSelectedRelatedWords(THashMap<String, Set<String>> rlMap) { Set<String> keys = rlMap.keySet(); THashSet<String> result = new THashSet<String>(); for (String key : keys) { if (key.equals("identity")/*||key.equals("synonym")||key.equals("derived-form")||key.equals("morph")*/) result.addAll(rlMap.get(key)); } return result; } }
THashSet<String> sameNumber = new THashSet<String>(); identity.addAll(rel.get(RelationType.idty)); synonym.addAll(rel.get(RelationType.synm)); synonym.addAll(rel.get(RelationType.syn2)); antonym.addAll(rel.get(RelationType.antm)); antonym.addAll(rel.get(RelationType.extd)); antonym.addAll(rel.get(RelationType.indi)); hypernym.addAll(rel.get(RelationType.hype)); hyponym.addAll(rel.get(RelationType.hypo)); derivedForm.addAll(rel.get(RelationType.derv)); morphSet.addAll(rel.get(RelationType.morph)); verbGroup.addAll(rel.get(RelationType.vgrp)); entailment.addAll(rel.get(RelationType.entl)); entailedBy.addAll(rel.get(RelationType.entlby)); seeAlso.addAll(rel.get(RelationType.alsoc)); causalRelation.addAll(rel.get(RelationType.cause)); if(sourceWord==null) { System.out.println("Problem. Source Word Null. Exiting");
public static THashSet<String> getRelatedWords(FNModelOptions options) throws IOException, ClassNotFoundException { String fmFile = options.frameNetMapFile.get(); String wnConfigFile = options.wnConfigFile.get(); String stopFile = options.stopWordsFile.get(); String luXmlDir = options.luXmlDir.get(); THashMap<String, THashSet<String>> mFrameMap = SerializedObjects.readObject(fmFile); WordNetRelations wnr = new WordNetRelations(stopFile, wnConfigFile); THashSet<String> set = getAllRelatedWords(mFrameMap, wnr); THashSet<String> absentExampleLUs = getListOfLUs(luXmlDir, wnr); set.addAll(absentExampleLUs); String relatedWordsFile = options.allRelatedWordsFile.get(); SerializedObjects.writeSerializedObject(set, relatedWordsFile); return set; }