当前位置: 首页>>代码示例>>Java>>正文


Java ChapmanLengthDeviation类代码示例

本文整理汇总了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]);
}
 
开发者ID:saikatgomes,项目名称:CS784-Data_Integration,代码行数:9,代码来源:ChapmanLengthDeviationFunction.java

示例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;
    }
}
 
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:45,代码来源:LengthDeviationAndCountingMatchesStrategy.java


注:本文中的uk.ac.shef.wit.simmetrics.similaritymetrics.ChapmanLengthDeviation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。