本文整理汇总了Java中no.priv.garshol.duke.Comparator类的典型用法代码示例。如果您正苦于以下问题:Java Comparator类的具体用法?Java Comparator怎么用?Java Comparator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Comparator类属于no.priv.garshol.duke包,在下文中一共展示了Comparator类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadDefaultComparators
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
private List<Comparator> loadDefaultComparators() {
String PKG = "no.priv.garshol.duke.comparators.";
String[] compnames = new String[] {
"DiceCoefficientComparator",
"DifferentComparator",
"ExactComparator",
"JaroWinkler",
"JaroWinklerTokenized",
"Levenshtein",
"NumericComparator",
"PersonNameComparator",
"SoundexComparator",
"WeightedLevenshtein",
"NorphoneComparator",
"MetaphoneComparator",
"QGramComparator",
"GeopositionComparator",
"LongestCommonSubstring",
};
List<Comparator> comparators = new ArrayList<Comparator>();
for (int ix = 0; ix < compnames.length; ix++)
comparators.add((Comparator)ObjectUtils.instantiate(PKG + compnames[ix]));
return comparators;
}
开发者ID:larsga,项目名称:Duke,代码行数:27,代码来源:GeneticConfiguration.java
示例2: makeComparator
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
private static Comparator makeComparator(String measure) {
switch (measure) {
case "jaccard":
case "JaccardIndex":
return new JaccardIndexComparator();
case "jw":
case "JaroWinkler":
// JaroWinkler Comparator contains bug which will be fixed in Duke 1.3 release.
// Before that happens, we duplicate the JaroWinkler comparator class with the bug fixed
return new H2OJaroWinklerComparator();
case "lv":
case "Levenshtein":
return new LevenshteinDistanceComparator();
case "lcs":
case "LongestCommonSubstring":
return new LongestCommonSubstring();
case "qgram":
case "QGram":
return new QGramComparator();
case "soundex":
case "Soundex":
return new SoundexComparator();
default:
throw new IllegalArgumentException("Unknown comparator: " + measure);
}
}
开发者ID:h2oai,项目名称:h2o-3,代码行数:27,代码来源:AstStrDistance.java
示例3: computeProb
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
private static double computeProb(Collection<String> vs1, Collection<String> vs2, Comparator comp, List<Cleaner> cleanersList, Double max, Double min) {
double high = 0.0;
for (String v1 : vs1) {
if (v1.equals("")) {
continue;
}
v2fieldloop:
for (String v2 : vs2) {
if (v2.equals("")) {
continue;
}
for (Cleaner cl : cleanersList) {
v2 = cl.clean(v2);
if ((v2 == null) || v2.equals("")) {
continue v2fieldloop;
}
}
double p = compare(v1, v2, max, min, comp);
high = Math.max(high, p);
}
}
return high;
}
开发者ID:YannBrrd,项目名称:elasticsearch-entity-resolution,代码行数:26,代码来源:EntityResolutionScript.java
示例4: compare
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
/**
* Returns the probability that the records v1 and v2 came from represent
* the same entity, based on high and low probability settings etc.
*
* @param v1 1st String
* @param v2 2nd String
* @param high max probability
* @param low min probability
* @param comparator the comparator to use
* @return the computed probability
*/
private static double compare(
final String v1,
final String v2,
final double high,
final double low,
final Comparator comparator) {
if (comparator == null) {
return AVERAGE_SCORE; // we ignore properties with no comparator
}
double sim = comparator.compare(v1, v2);
if (sim < AVERAGE_SCORE) {
return low;
} else {
return ((high - AVERAGE_SCORE) * (sim * sim)) + AVERAGE_SCORE;
}
}
开发者ID:YannBrrd,项目名称:elasticsearch-entity-resolution,代码行数:30,代码来源:EntityResolutionScript.java
示例5: GeneticConfiguration
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
/**
* Creates an initial copy of the starting configuration, with no
* changes. Used to initialize the aspects list.
* @param mutation_rate Mutation rate. -1 if self-evolving.
* @param recombination_rate Recombination rate. -1.0 if self-evolving.
* @param evolve_comparators If false the comparators will be left as
* in the original configuration and not evolved.
*/
public GeneticConfiguration(Configuration config, int mutation_rate,
double recombination_rate,
boolean evolve_comparators) {
this.config = config;
List<Comparator> comparators = loadDefaultComparators();
comparators.addAll(config.getCustomComparators());
this.aspects = new ArrayList();
aspects.add(new ThresholdAspect());
for (Property prop : config.getProperties()) {
if (!prop.isIdProperty()) {
if (evolve_comparators)
aspects.add(new ComparatorAspect(prop, comparators));
aspects.add(new LowProbabilityAspect(prop));
aspects.add(new HighProbabilityAspect(prop));
}
}
if (mutation_rate == -1)
aspects.add(new MutationRateAspect());
else
this.mutation_rate = mutation_rate;
if (recombination_rate == -1.0)
aspects.add(new RecombinationRateAspect());
else
this.recombination_rate = recombination_rate;
}
开发者ID:enricopal,项目名称:STEM,代码行数:36,代码来源:GeneticConfiguration.java
示例6: loadDefaultComparators
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
private List<Comparator> loadDefaultComparators() {
String PKG = "no.priv.garshol.duke.comparators.";
String[] compnames = new String[] {
"DiceCoefficientComparator",
"DifferentComparator",
"ExactComparator",
"JaroWinkler",
"JaroWinklerTokenized",
"Levenshtein",
"NumericComparator",
"PersonNameComparator",
"SoundexComparator",
"WeightedLevenshtein",
"NorphoneComparator",
"MetaphoneComparator",
"QGramComparator",
"GeopositionComparator",
"LongestCommonSubstring",
"XSDDateTimeComparator"
};
List<Comparator> comparators = new ArrayList<Comparator>();
for (int ix = 0; ix < compnames.length; ix++)
comparators.add((Comparator)ObjectUtils.instantiate(PKG + compnames[ix]));
return comparators;
}
开发者ID:enricopal,项目名称:STEM,代码行数:28,代码来源:GeneticConfiguration.java
示例7: canAddCustomComparator
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
@Test
public void canAddCustomComparator() {
GeneticConfiguration conf = new GeneticConfiguration(config1);
Property aspectProp = new PropertyImpl(propName, null, 0.5, 0.5);
List<Comparator> compList = new ArrayList<Comparator>();
compList.add(comparator);
ComparatorAspect aspect = new ComparatorAspect(aspectProp, compList);
aspect.setRandomly(conf);
Property updatedProp = config1.getPropertyByName(propName);
Comparator randomComparator = updatedProp.getComparator();
assertTrue("should have custom comparator set, but has : " + randomComparator.getClass(), randomComparator.equals(comparator));
}
开发者ID:enricopal,项目名称:STEM,代码行数:15,代码来源:ComparatorAspectTest.java
示例8: testCustomComparator
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
@Test
public void testCustomComparator() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-custom-comparator.xml");
List<Comparator> comparators = config.getCustomComparators();
assertEquals(1, comparators.size());
}
开发者ID:enricopal,项目名称:STEM,代码行数:9,代码来源:ConfigLoaderTest.java
示例9: testCustomEstimator
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
@Test
public void testCustomEstimator() throws IOException, SAXException {
Configuration config = ConfigLoader.load("classpath:config-custom-estimator.xml");
List<Comparator> comparators = config.getCustomComparators();
assertEquals(1, comparators.size());
WeightedLevenshtein wl = (WeightedLevenshtein) comparators.get(0);
DefaultWeightEstimator est = (DefaultWeightEstimator) wl.getEstimator();
assertEquals(3.8, est.getDigitWeight());
}
开发者ID:enricopal,项目名称:STEM,代码行数:12,代码来源:ConfigLoaderTest.java
示例10: configureWithFieldsOnly
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
/**
* . Configures with data from JSON payload only
*
* @param fieldsParams fields parameters from JSON
* @return the record for comparison
*/
private Record configureWithFieldsOnly(
final List<Map<String, Object>> fieldsParams) {
Map<String, Collection<String>> props =
new HashMap<>();
entityParams = new HashMap<>();
for (Map<String, Object> value : fieldsParams) {
HashMap<String, Object> map = new HashMap<>();
String field = (String) value.get("field");
List<Cleaner> cleanList =
getCleaners((ArrayList<Map<String, String>>) value.get(CLEANERS));
map.put(CLEANERS, cleanList);
Double maxValue = 0.0;
if (value.get(HIGH) != null) {
maxValue = (Double) value.get(HIGH);
}
Double minValue = 0.0;
if (value.get(LOW) != null) {
minValue = (Double) value.get(LOW);
}
Comparator comp = getComparator(value);
map.put(HIGH, maxValue);
map.put(LOW, minValue);
map.put(COMPARATOR, comp);
entityParams.put(field, map);
}
readFields(fieldsParams, props);
return new RecordImpl(props);
}
开发者ID:YannBrrd,项目名称:elasticsearch-entity-resolution,代码行数:46,代码来源:EntityResolutionScript.java
示例11: isFuzzy
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
private boolean isFuzzy(String fieldName) {
Comparator c = config.getPropertyByName(fieldName).getComparator();
return c != null && c.isTokenized();
}
开发者ID:enricopal,项目名称:STEM,代码行数:5,代码来源:LuceneDatabase.java
示例12: ComparatorAspect
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
public ComparatorAspect(Property prop, List<Comparator> comparators) {
this.prop = prop;
this.comparators = comparators;
}
开发者ID:enricopal,项目名称:STEM,代码行数:5,代码来源:ComparatorAspect.java
示例13: shortname
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
private String shortname(Comparator comp) {
return comp.getClass().getSimpleName();
}
开发者ID:enricopal,项目名称:STEM,代码行数:4,代码来源:GeneticConfiguration.java
示例14: setComparator
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
public void setComparator(Comparator comp) {
this.subcomp = comp;
}
开发者ID:enricopal,项目名称:STEM,代码行数:4,代码来源:JaccardIndexComparator.java
示例15: testSmallData
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
@Test
public void testSmallData() throws IOException {
File outfile = tmpdir.newFile("test.csv");
FileWriter out = new FileWriter(outfile);
out.write("id;name;age\n");
out.write("1;LMG;39\n");
out.write("2;GOG;40\n");
out.write("3;GDM;29\n");
out.write("4;AB;49\n");
out.close();
File tstfile = tmpdir.newFile("testfile.csv");
out = new FileWriter(tstfile);
out.close();
CSVDataSource csv = new CSVDataSource();
csv.setSeparator(';');
csv.setInputFile(outfile.getAbsolutePath());
csv.addColumn(new Column("id", null, null, null));
csv.addColumn(new Column("name", null, null, null));
csv.addColumn(new Column("age", null, null, null));
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.addDatabase(new InMemoryDatabase());
cfg.addDataSource(0, csv);
Comparator cmp = new ExactComparator();
List<Property> props = new ArrayList();
props.add(new PropertyImpl("id"));
props.add(new PropertyImpl("name", cmp, 0.0, 1.0));
props.add(new PropertyImpl("age", cmp, 0.0, 1.0));
cfg.setProperties(props);
GeneticAlgorithm gen = new GeneticAlgorithm(cfg,
tstfile.getAbsolutePath(),
true);
gen.setQuiet(true);
gen.run(); // should not crash!
}
开发者ID:enricopal,项目名称:STEM,代码行数:43,代码来源:ActiveLearningTest.java
示例16: testSmallData
import no.priv.garshol.duke.Comparator; //导入依赖的package包/类
@Test
public void testSmallData() throws IOException {
File outfile = tmpdir.newFile("test.csv");
FileWriter out = new FileWriter(outfile);
out.write("id;name;age\n");
out.write("1;LMG;39\n");
out.write("2;GOG;40\n");
out.write("3;GDM;29\n");
out.write("4;AB;49\n");
out.close();
File tstfile = tmpdir.newFile("testfile.csv");
out = new FileWriter(tstfile);
out.close();
CSVDataSource csv = new CSVDataSource();
csv.setSeparator(';');
csv.setInputFile(outfile.getAbsolutePath());
csv.addColumn(new Column("id", null, null, null));
csv.addColumn(new Column("name", null, null, null));
csv.addColumn(new Column("age", null, null, null));
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.addDatabase(new InMemoryDatabase());
cfg.addDataSource(0, csv);
Comparator cmp = new ExactComparator();
List<Property> props = new ArrayList();
props.add(new PropertyImpl("id"));
props.add(new PropertyImpl("name", cmp, 0.0, 1.0));
props.add(new PropertyImpl("age", cmp, 0.0, 1.0));
cfg.setProperties(props);
GeneticAlgorithm gen = new GeneticAlgorithm(cfg, tstfile.getAbsolutePath(),
true);
gen.setQuiet(true);
gen.run(); // should not crash!
}
开发者ID:larsga,项目名称:Duke,代码行数:42,代码来源:ActiveLearningTest.java
注:本文中的no.priv.garshol.duke.Comparator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论