本文整理汇总了Java中uk.ac.shef.wit.simmetrics.similaritymetrics.ChapmanLengthDeviation类的典型用法代码示例。如果您正苦于以下问题:Java ChapmanLengthDeviation类的具体用法?Java ChapmanLengthDeviation怎么用?Java ChapmanLengthDeviation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChapmanLengthDeviation类属于uk.ac.shef.wit.simmetrics.similaritymetrics包,在下文中一共展示了ChapmanLengthDeviation类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import uk.ac.shef.wit.simmetrics.similaritymetrics.ChapmanLengthDeviation; //导入依赖的package包/类
@Override
public Float compute(String[] args) throws IllegalArgumentException{
if(args.length != NUM_ARGS){
throw new IllegalArgumentException("Expected number of arguments: " + NUM_ARGS);
}
AbstractStringMetric metric = new ChapmanLengthDeviation();
return metric.getSimilarity(args[0], args[1]);
}
示例2: determineAuthenticatedUser
import uk.ac.shef.wit.simmetrics.similaritymetrics.ChapmanLengthDeviation; //导入依赖的package包/类
@Override
public ServiceProvider.User determineAuthenticatedUser(String pageSource, String url, ServiceProvider serviceProvider) {
float success = 0.0f;
float failure = 0.0f;
AbstractStringMetric metric = new ChapmanLengthDeviation();
for (String attackerSuccessPageSource: serviceProvider.getAttackerSuccessPageSources()) {
float currentSuccess = metric.getSimilarity(pageSource, attackerSuccessPageSource);
//System.out.println("success: " + currentSuccess);
success += currentSuccess;
}
for (String failurePageSource: serviceProvider.getFailurePageSources()) {
float currentFailure = metric.getSimilarity(pageSource, failurePageSource);
//System.out.println("failure: " + currentFailure);
failure += currentFailure;
}
if (success > failure) {
String victimUsername = serviceProvider.getVictimUsername();
String attackerUsername = serviceProvider.getAttackerUsername();
int victimMatches = StringUtils.countMatches(pageSource, StringUtils.capitalize(victimUsername));
victimMatches += StringUtils.countMatches(pageSource, victimUsername.toLowerCase());
int attackerMatches = StringUtils.countMatches(pageSource, StringUtils.capitalize(attackerUsername));
attackerMatches += StringUtils.countMatches(pageSource, attackerUsername.toLowerCase());
//System.out.println("victimMatches: " + victimMatches + ", attackerMatches: " + attackerMatches);
if (victimMatches > attackerMatches) {
return ServiceProvider.User.VICTIM;
} else if (attackerMatches > victimMatches) {
return ServiceProvider.User.ATTACKER;
} else {
return ServiceProvider.User.NONE;
}
} else {
return User.ERROR;
}
}