Java Code Examples for gnu.trove.set.hash.THashSet#iterator()
The following examples show how to use
gnu.trove.set.hash.THashSet#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DictPOS.java From fnlp with GNU Lesser General Public License v3.0 | 6 votes |
public void load(String in) throws IOException{ int begin = in.lastIndexOf("\\"); int idx = in.indexOf('-',begin); if(idx==-1) idx = in.indexOf('.',begin); if(idx==-1) idx = in.length(); String pos = in.substring(begin+1,idx); THashSet<String> set = MyCollection.loadTSet(in); TObjectHashIterator<String> it = set.iterator(); while(it.hasNext()){ String s = it.next(); s = s.replaceAll("(\\s| | |\\t)+", ""); if(s.length()==0) continue; add(pos, s); String ss = filter(pos,s); if(ss!=null){ add(pos,ss); } } }
Example 2
Source File: JaccardSimilarity.java From fnlp with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example 3
Source File: MyCollection.java From fnlp with GNU Lesser General Public License v3.0 | 5 votes |
public static void TSet2List(THashSet<String> newset, ArrayList<String> al) { TObjectHashIterator<String> it = newset.iterator(); while(it.hasNext()){ String s = it.next(); al.add(s); } }
Example 4
Source File: MyCollection.java From fnlp with GNU Lesser General Public License v3.0 | 5 votes |
public static int getLength(THashSet<String> set) { int i = 0; TObjectHashIterator<String> it = set.iterator(); while(it.hasNext()){ String s = it.next(); if(s.length()>i) i=s.length(); } return i; }
Example 5
Source File: RLSeg.java From fnlp with GNU Lesser General Public License v3.0 | 4 votes |
int update(String[] toks) throws IOException { if(toks==null) return 0; THashSet<String> newdict = new THashSet<String>(); String nowords = ""; int count = 0; for(int i=0;i<toks.length;i++){//取得包含新词的最长子串 if(Chars.isLetterOrDigitOrPunc(toks[i])) continue; if(!dict.contains(toks[i])&&!tempdict.contains(toks[i])){ nowords += "" + toks[i]; count++; }else{ 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); bwNo.write("\n"); } } bwNew.flush(); bwNo.flush(); return count; }