/** Default way to preprocess a string for distance computation. If * this is an expensive operations, then override this method to * return a StringWrapper implementation that caches appropriate * information about s. */ public StringWrapper prepare(String s) { return new BasicStringWrapper(s); }
/** Default way to preprocess a string for distance computation. If * this is an expensive operations, then override this method to * return a StringWrapper implementation that caches appropriate * information about s. */ public StringWrapper prepare(String s) { return new BasicStringWrapper(s); }
/** Default way to preprocess a string for distance computation. If * this is an expensive operations, then override this method to * return a StringWrapper implementation that caches appropriate * information about s. */ public StringWrapper prepare(String s) { return new BasicStringWrapper(s); }
public StringWrapper prepare(String s) { return new BasicStringWrapper(s.toLowerCase()); }
public StringWrapper prepare(String s) { return new BasicStringWrapper(s.toLowerCase()); }
public StringWrapper prepare(String s) { return new BasicStringWrapper(s.toLowerCase()); }
/** Create a MultiStringWrapper by making k copies of each field of s. */ public MultiStringWrapper(String s, int numCopies, String delim) { super(s); this.s = s; String[] fields; if (delim!=null) fields = s.split(delim,-1); else fields = new String[]{s}; f = new StringWrapper[ fields.length * numCopies ]; learnerIndex = new int[ f.length ]; fieldIndex = new int[ f.length ]; for (int i=0; i<fields.length; i++) { for (int j=0; j<numCopies; j++) { int k = i*numCopies+j; f[k] = new BasicStringWrapper(fields[i]); learnerIndex[k] = j; fieldIndex[k] = i; } } fieldsPrepared = false; }
/** Create a MultiStringWrapper by making k copies of each field of s. */ public MultiStringWrapper(String s, int numCopies, String delim) { super(s); this.s = s; String[] fields; if (delim!=null) fields = s.split(delim,-1); else fields = new String[]{s}; f = new StringWrapper[ fields.length * numCopies ]; learnerIndex = new int[ f.length ]; fieldIndex = new int[ f.length ]; for (int i=0; i<fields.length; i++) { for (int j=0; j<numCopies; j++) { int k = i*numCopies+j; f[k] = new BasicStringWrapper(fields[i]); learnerIndex[k] = j; fieldIndex[k] = i; } } fieldsPrepared = false; }
/** Create a MultiStringWrapper by making k copies of each field of s. */ public MultiStringWrapper(String s, int numCopies, String delim) { super(s); this.s = s; String[] fields; if (delim!=null) fields = s.split(delim,-1); else fields = new String[]{s}; f = new StringWrapper[ fields.length * numCopies ]; learnerIndex = new int[ f.length ]; fieldIndex = new int[ f.length ]; for (int i=0; i<fields.length; i++) { for (int j=0; j<numCopies; j++) { int k = i*numCopies+j; f[k] = new BasicStringWrapper(fields[i]); learnerIndex[k] = j; fieldIndex[k] = i; } } fieldsPrepared = false; }
private StringWrapper prepare(String s) { StringWrapperIterator i = distanceLearner.prepare( new BasicStringWrapperIterator( Collections.singleton(new BasicStringWrapper(s)).iterator()) ); return i.nextStringWrapper(); } public String toString() { return "[SoftDictionaryWrapper '"+unwrap()+"']"; }
private StringWrapper prepare(String s) { StringWrapperIterator i = distanceLearner.prepare( new BasicStringWrapperIterator( Collections.singleton(new BasicStringWrapper(s)).iterator()) ); return i.nextStringWrapper(); } public String toString() { return "[SoftDictionaryWrapper '"+unwrap()+"']"; }
private StringWrapper prepare(String s) { StringWrapperIterator i = distanceLearner.prepare( new BasicStringWrapperIterator( Collections.singleton(new BasicStringWrapper(s)).iterator()) ); return i.nextStringWrapper(); } public String toString() { return "[SoftDictionaryWrapper '"+unwrap()+"']"; }
/** * Test if titles match * In this implementation the jaro similarity metric is used to compare string values. * Very similar strings will have a jaro score close to 1. Different strings have a * jaro score close to 0. * @param s1 title 1 * @param s2 title 2 * @return true if jaro.score(title1, title2) > threshold (threshold defaults to 0.9) */ public boolean valuesMatch(String s1, String s2) { StringWrapper sw1 = new BasicStringWrapper(s1); StringWrapper sw2 = new BasicStringWrapper(s2); Jaro jro = new Jaro(); double tmp = jro.score(sw1, sw2); if (tmp > threshold) return true; else return false; }
final public StringWrapper prepare(String s) { MultiStringWrapper ms = asMultiStringWrapper(new BasicStringWrapper(s)); ms.prepare( innerDistances ); return ms; }
final public StringWrapper prepare(String s) { MultiStringWrapper ms = asMultiStringWrapper(new BasicStringWrapper(s)); ms.prepare( innerDistances ); return ms; }
ApproxMemoMatrix(StringWrapper s,StringWrapper t,int width,double defaultValue) { super(new BasicStringWrapper(""),new BasicStringWrapper("")); this.s = s; this.t = t; this.valuesNearDiagonal = new double[s.length()+1][2*width]; this.wasComputed = new boolean[s.length()+1][2*width]; this.defaultValue = defaultValue; this.width = width; this.scale = (t.length()+1.0)/(s.length()+1.0); }
ApproxMemoMatrix(StringWrapper s,StringWrapper t,int width,double defaultValue) { super(new BasicStringWrapper(""),new BasicStringWrapper("")); this.s = s; this.t = t; this.valuesNearDiagonal = new double[s.length()+1][2*width]; this.wasComputed = new boolean[s.length()+1][2*width]; this.defaultValue = defaultValue; this.width = width; this.scale = (t.length()+1.0)/(s.length()+1.0); }
ApproxMemoMatrix(StringWrapper s,StringWrapper t,int width,double defaultValue) { super(new BasicStringWrapper(""),new BasicStringWrapper("")); this.s = s; this.t = t; this.valuesNearDiagonal = new double[s.length()+1][2*width]; this.wasComputed = new boolean[s.length()+1][2*width]; this.defaultValue = defaultValue; this.width = width; this.scale = (t.length()+1.0)/(s.length()+1.0); }
final public StringWrapper prepare(String s) { MultiStringWrapper ms = asMultiStringWrapper(new BasicStringWrapper(s)); ms.prepare( innerDistances ); return ms; }