• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NeedlemanWunsch类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.wcohen.ss.NeedlemanWunsch的典型用法代码示例。如果您正苦于以下问题:Java NeedlemanWunsch类的具体用法?Java NeedlemanWunsch怎么用?Java NeedlemanWunsch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

NeedlemanWunsch类属于com.wcohen.ss包,在下文中一共展示了NeedlemanWunsch类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getNeedlemanWunsch_Distance

点赞 2

import com.wcohen.ss.NeedlemanWunsch; //导入依赖的package包/类
/**
 * NeedlemanWunsch distance is a measure of the similarity between two strings, which we will refer to as the source
 * string (s) and the target string (t). The distance is the number of deletions, insertions, or substitutions
 * required to transform s into t.
 */
public static Long getNeedlemanWunsch_Distance( ValueMetaInterface metaA, Object dataA,
  ValueMetaInterface metaB, Object dataB ) {
  if ( dataA == null || dataB == null ) {
    return null;
  }
  return new Long( (int) new NeedlemanWunsch().score( dataA.toString(), dataB.toString() ) );
}
 

开发者ID:pentaho,
项目名称:pentaho-kettle,
代码行数:13,
代码来源:ValueDataUtil.java

示例2: doDistance

点赞 2

import com.wcohen.ss.NeedlemanWunsch; //导入依赖的package包/类
private Object[] doDistance(Object[] row) throws KettleValueException {
  	// Reserve room
Object[] rowData = buildEmptyRow();

  	Iterator<Object[]> it = data.look.iterator();

long distance=-1;	

// Object o=row[data.indexOfMainField];
String lookupvalue = getInputRowMeta().getString(row, data.indexOfMainField);	

while (it.hasNext()){
	// Get cached row data
	Object[] cachedData = (Object[]) it.next(); 
	// Key value is the first value
	String cacheValue= (String) cachedData[0];

	int cdistance = -1;
	String usecacheValue=cacheValue;
	String uselookupvalue=lookupvalue;
	if(!meta.isCaseSensitive()) {
		usecacheValue=cacheValue.toLowerCase();
		uselookupvalue=lookupvalue.toLowerCase();	
	}
	
	switch (meta.getAlgorithmType()) {
   		case FuzzyMatchMeta.OPERATION_TYPE_DAMERAU_LEVENSHTEIN:
   			cdistance = Utils.getDamerauLevenshteinDistance(usecacheValue,uselookupvalue);
   			break;
   		case FuzzyMatchMeta.OPERATION_TYPE_NEEDLEMAN_WUNSH:
   			cdistance= Math.abs((int) new NeedlemanWunsch().score(usecacheValue, uselookupvalue));
   			break;
   		default:
   			cdistance = StringUtils.getLevenshteinDistance(usecacheValue,uselookupvalue);	
   			break;
	}
	
	if (data.minimalDistance <= cdistance && cdistance <= data.maximalDistance) {
		if(meta.isGetCloserValue()) {
			if(cdistance<distance || distance==-1)   {
				// Get closer value
				// minimal distance
				distance= cdistance;
				int index=0;
				rowData[index++]=cacheValue;
				// Add metric value?
				if(data.addValueFieldName) 	{
					rowData[index++]= distance;
				}
				// Add additional return values?
				if(data.addAdditionalFields) {
					for(int i=0; i<meta.getValue().length; i++) {
						int nr=i+1;
						int nf=i+index;
						rowData[nf] = cachedData[nr];
					}
				}
			}
		}else {
			// get all values separated by values separator
			if(rowData[0]==null) rowData[0]=cacheValue; else rowData[0]= (String)rowData[0] + data.valueSeparator + cacheValue;
		}
	}
}


return rowData;
  }
 

开发者ID:yintaoxue,
项目名称:read-open-source-code,
代码行数:69,
代码来源:FuzzyMatch.java

示例3: getNeedlemanWunsch_Distance

点赞 2

import com.wcohen.ss.NeedlemanWunsch; //导入依赖的package包/类
/**NeedlemanWunsch distance is a measure of the similarity between two strings, 
 * which we will refer to as the source string (s) and the target string (t). 
 * The distance is the number of deletions, insertions, or substitutions required to transform s into t. 
 */
public static Long getNeedlemanWunsch_Distance(ValueMetaInterface metaA, Object dataA, ValueMetaInterface metaB, Object dataB)
{
	if(dataA==null || dataB==null) return null;
	return new Long((int) new NeedlemanWunsch().score(dataA.toString(),dataB.toString()));
}
 

开发者ID:yintaoxue,
项目名称:read-open-source-code,
代码行数:10,
代码来源:ValueDataUtil.java

示例4: doDistance

点赞 2

import com.wcohen.ss.NeedlemanWunsch; //导入依赖的package包/类
private Object[] doDistance( Object[] row ) throws KettleValueException {
  // Reserve room
  Object[] rowData = buildEmptyRow();

  Iterator<Object[]> it = data.look.iterator();

  long distance = -1;

  // Object o=row[data.indexOfMainField];
  String lookupvalue = getInputRowMeta().getString( row, data.indexOfMainField );

  while ( it.hasNext() ) {
    // Get cached row data
    Object[] cachedData = it.next();
    // Key value is the first value
    String cacheValue = (String) cachedData[0];

    int cdistance = -1;
    String usecacheValue = cacheValue;
    String uselookupvalue = lookupvalue;
    if ( !meta.isCaseSensitive() ) {
      usecacheValue = cacheValue.toLowerCase();
      uselookupvalue = lookupvalue.toLowerCase();
    }

    switch ( meta.getAlgorithmType() ) {
      case FuzzyMatchMeta.OPERATION_TYPE_DAMERAU_LEVENSHTEIN:
        cdistance = Utils.getDamerauLevenshteinDistance( usecacheValue, uselookupvalue );
        break;
      case FuzzyMatchMeta.OPERATION_TYPE_NEEDLEMAN_WUNSH:
        cdistance = Math.abs( (int) new NeedlemanWunsch().score( usecacheValue, uselookupvalue ) );
        break;
      default:
        cdistance = StringUtils.getLevenshteinDistance( usecacheValue, uselookupvalue );
        break;
    }

    if ( data.minimalDistance <= cdistance && cdistance <= data.maximalDistance ) {
      if ( meta.isGetCloserValue() ) {
        if ( cdistance < distance || distance == -1 ) {
          // Get closer value
          // minimal distance
          distance = cdistance;
          int index = 0;
          rowData[index++] = cacheValue;
          // Add metric value?
          if ( data.addValueFieldName ) {
            rowData[index++] = distance;
          }
          // Add additional return values?
          if ( data.addAdditionalFields ) {
            for ( int i = 0; i < meta.getValue().length; i++ ) {
              int nr = i + 1;
              int nf = i + index;
              rowData[nf] = cachedData[nr];
            }
          }
        }
      } else {
        // get all values separated by values separator
        if ( rowData[0] == null ) {
          rowData[0] = cacheValue;
        } else {
          rowData[0] = (String) rowData[0] + data.valueSeparator + cacheValue;
        }
      }
    }
  }

  return rowData;
}
 

开发者ID:pentaho,
项目名称:pentaho-kettle,
代码行数:72,
代码来源:FuzzyMatch.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)