int update(String[] toks) throws IOException { if(toks==null) return 0; THashSet<String> newdict = new THashSet<String>(); String nowords = ""; int count = 0; if(!dict.contains(toks[i])&&!tempdict.contains(toks[i])){ nowords += "" + toks[i]; count++; if(nowords.length()>0){ System.out.println(nowords); newdict.add(nowords.trim()); nowords = ""; TObjectHashIterator<String> it = newdict.iterator(); while(it.hasNext()){ String s = it.next(); if(nodict.contains(s)) continue; System.out.println("搜索: "+s); THashSet<String> sset = getNewWords(s); if(sset==null||sset.size()==0) continue; System.out.println(sset); tempdict.addAll(sset); if(!sset.contains(s)&&!nodict.contains(s)){ nodict.add(s); bwNo.write(s);
public THashSet<String> getNewWords(String s) throws IOException { if(s.length()==0) return null; THashSet<String> newset = new THashSet<String>(); HashMap<String,Float> map = new HashMap<String, Float>(); String q = genQuery(s); if(w.length()<2||dict.contains(w)||tempdict.contains(w)) continue; for(Entry e:list){ String ss = (String) e.getKey(); if((Float) e.getValue()>thres&&ss.length()>1&&!dict.contains(ss)&&!tempdict.contains(ss)){ newset.add(ss); bwNew.write(ss); bwNew.write("\n"); newset.remove("快照"); return newset;
@SuppressWarnings({"SimplifiableIfStatement"}) public boolean equals(Object other) { if (!(other instanceof Set)) { return false; } Set that = (Set) other; if (that.size() != this.size()) { return false; } return containsAll(that); }
public float calc(THashSet<Object> s1, THashSet<Object> s2) { int com = 0; if (s1 == null || s2 == null) return 0; TObjectHashIterator<Object> it = s1.iterator(); for ( int i = s1.size(); i-- > 0; ) { Object v = it.next(); if(s2.contains(v)) com++; } float sim = ((float) com)/(s1.size()+s2.size()-com); return sim; } }
public Dictionary() { dict = new THashSet<String>(); } /**
THashSet<Chunk> set = new THashSet<>(); if (chunk.setBlockState(pos, replState) != null) { ++blockCounter; set.add(chunk); if (chunk.setBlockState(pos, replState) != null) { ++blockCounter; set.add(chunk); if (chunk.setBlockState(pos, replState) != null) { ++blockCounter; set.add(chunk); if (chunk.setBlockState(pos, replState) != null) { ++blockCounter; set.add(chunk); if (chunk.setBlockState(pos, replState) != null) { ++blockCounter; set.add(chunk); if (chunk.setBlockState(pos, replState) != null) { ++blockCounter; set.add(chunk); if (chunk.setBlockState(pos, replState) != null) { ++blockCounter; set.add(chunk);
public ItemPickaxeCore(ToolMaterial toolMaterial) { super(2.0F, -2.8F, toolMaterial); addToolClass("pickaxe"); effectiveBlocks.addAll(ItemPickaxe.EFFECTIVE_ON); effectiveMaterials.add(Material.IRON); effectiveMaterials.add(Material.ANVIL); effectiveMaterials.add(Material.ROCK); effectiveMaterials.add(Material.ICE); effectiveMaterials.add(Material.PACKED_ICE); effectiveMaterials.add(Material.GLASS); effectiveMaterials.add(Material.REDSTONE_LIGHT); }
/** * 读取不带词频的字典 * @param dict * @param string * @param file * @throws IOException */ public void readDictionary(String path, String suffix) throws IOException { List<File> dicts = MyFiles.getAllFiles(path, suffix); for(File fdict: dicts){ BufferedReader bfr = new BufferedReader(new InputStreamReader(new FileInputStream(fdict),"utf8")); String line = null; while ((line = bfr.readLine()) != null) { line = line.replaceAll("(\\s| | |\\t)+", ""); if(line.length()==0||set.contains(line)) continue; set.add(line); } bfr.close(); } } /**
public static int isContain(THashSet<String> set, ArrayList<String> subwords) { int i = 0; for(String s: subwords){ if(set.contains(s)) i++; } return i; }
THashSet<String> calculateCommonLeafes(TreePair pair) { THashSet<String> ts1 = treeToTaxa.get(pair.t1); THashSet<String> ts2 = treeToTaxa.get(pair.t2); if (ts1 == null) { ts1 = createTreeEntry(pair.t1); } if (ts2 == null) { ts2 = createTreeEntry(pair.t2); } THashSet<String> tcommon = new THashSet<>(ts1.size()); tcommon.addAll(ts1); tcommon.retainAll(ts2); return tcommon; }
/** * Removes any values in the set which are not contained in * <tt>collection</tt>. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the retain all operation */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll(Collection<?> collection) { boolean changed = false; int size = size(); Iterator<E> it = iterator(); while (size-- > 0) { if (!collection.contains(it.next())) { it.remove(); changed = true; } } return changed; }
private void gramPerString(String str) { String s = "^" + str + "*"; for (int i = 1; i < s.length() - 1; i++) { String c = s.substring(i, i+1); if (cmap.containsKey(c)) { String temp = s.substring(i-1, i) + s.substring(i+1, i+2); int id = cmap.get(c); hashlist.get(id).add(temp); } } }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @SuppressWarnings({"unchecked"}) protected void rehash(int newCapacity) { int oldCapacity = _set.length; int oldSize = size(); Object oldSet[] = _set; _set = new Object[newCapacity]; Arrays.fill(_set, FREE); int count = 0; for (int i = oldCapacity; i-- > 0;) { E o = (E) oldSet[i]; if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } // count++; } } // Last check: size before and after should be the same reportPotentialConcurrentMod(size(), oldSize); }
/** * Creates a new <code>THashSet</code> instance containing the * elements of <tt>collection</tt>. * * @param collection a <code>Collection</code> value */ public THashSet(Collection<? extends E> collection) { this(collection.size()); addAll(collection); }
/** * Adds all of the elements in <tt>collection</tt> to the set. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the add all operation. */ public boolean addAll(Collection<? extends E> collection) { boolean changed = false; int size = collection.size(); ensureCapacity(size); Iterator<? extends E> it = collection.iterator(); while (size-- > 0) { if (add(it.next())) { changed = true; } } return changed; }
@SuppressWarnings({"unchecked"}) public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION byte version = in.readByte(); // NOTE: super was not written in version 0 if (version != 0) { super.readExternal(in); } // NUMBER OF ENTRIES int size = in.readInt(); setUp(size); // ENTRIES while (size-- > 0) { E val = (E) in.readObject(); add(val); } } } // THashSet
/** * Removes all of the elements in <tt>collection</tt> from the set. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the remove all operation. */ public boolean removeAll(Collection<?> collection) { boolean changed = false; int size = collection.size(); Iterator it; it = collection.iterator(); while (size-- > 0) { if (remove(it.next())) { changed = true; } } return changed; }