public override double stringDistance(String stringA, String stringB) { HashSet<string> ha = new HashSet<string>(); HashSet<string> hb = new HashSet<string>(); long pos = ms.Position; tw.WriteLine(stringA); tw.Flush(); ms.Position = pos; Lucene.Net.Analysis.Token t = filt.Next(); while (t != null) { ha.Add(t.TermText()); t = filt.Next(); } pos = ms.Position; tw.WriteLine(stringB); tw.Flush(); ms.Position = pos; Lucene.Net.Analysis.Token tb = filt.Next(); while (tb != null) { hb.Add(tb.TermText()); tb = filt.Next(); } double uc = ha.Union(hb).Count(); double ic = ha.Intersect(hb).Count(); return (uc - ic) / uc; }
public bool retainAll(java.util.Collection c) { JavaIteratorWrapper<dotSesame.Statement> stmtIter = new JavaIteratorWrapper<org.openrdf.model.Statement>(c.iterator()); HashSet<Triple> retained = new HashSet<Triple>(); bool changed = false; foreach (dotSesame.Statement stmt in stmtIter) { retained.Add(SesameConverter.FromSesame(stmt, this._mapping)); } foreach (Triple t in this._g.Triples.ToList()) { if (!retained.Contains(t)) { changed = true; this._g.Retract(t); } } return changed; }