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


Java LabelAlphabet.size方法代码示例

本文整理汇总了Java中cc.mallet.types.LabelAlphabet.size方法的典型用法代码示例。如果您正苦于以下问题:Java LabelAlphabet.size方法的具体用法?Java LabelAlphabet.size怎么用?Java LabelAlphabet.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.mallet.types.LabelAlphabet的用法示例。


在下文中一共展示了LabelAlphabet.size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: print

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public void print () 
{		
	final Alphabet dict = getAlphabet();
	final LabelAlphabet labelDict = getLabelAlphabet();
			
	int numFeatures = dict.size() + 1;
	int numLabels = labelDict.size();
	
	 // Include the feature weights according to each label
	 for (int li = 0; li < numLabels; li++) {
	 	System.out.println ("FEATURES FOR CLASS "+labelDict.lookupObject (li));
	 	System.out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex]);
	 	for (int i = 0; i < defaultFeatureIndex; i++) {
	 		Object name = dict.lookupObject (i);
            double weight = parameters [li*numFeatures + i];
	 		System.out.println (" "+name+" "+weight);
	 	}
	 }
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:20,代码来源:MCMaxEnt.java

示例2: createLabelVector

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
/** Constructs a LabelVector which is a distribution over indices of
 * the "positive" Instance. */
private LabelVector createLabelVector (LabelAlphabet labelAlphabet, double[] scores) {
	if (labelAlphabet.growthStopped())
		labelAlphabet.startGrowth();
	
	for (int i=0; i < scores.length; i++) 
		labelAlphabet.lookupIndex(String.valueOf(i), true);

	double[] allScores = new double[labelAlphabet.size()];

	for (int i=0; i < labelAlphabet.size(); i++) 
		allScores[i] = 0.0;

	for (int i=0; i < scores.length; i++) {
		int index = labelAlphabet.lookupIndex(String.valueOf(i), true);
		allScores[index] = scores[i];
	}
	return new LabelVector(labelAlphabet, allScores);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:21,代码来源:RankMaxEnt.java

示例3: print

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public void print () 
{		
	final Alphabet dict = getAlphabet();
	final LabelAlphabet labelDict = (LabelAlphabet)getLabelAlphabet();
	
	int numFeatures = dict.size() + 1;
	int numLabels = labelDict.size();
	
	// Include the feature weights according to each label
	//for (int li = 0; li < numLabels; li++) {
	System.out.println ("FEATURES FOR CLASS "+labelDict.lookupObject (0));
	System.out.println (" <default> "+parameters [defaultFeatureIndex]);
	for (int i = 0; i < defaultFeatureIndex; i++) {
		Object name = dict.lookupObject (i);
		double weight = parameters [i];
		System.out.println (" "+name+" "+weight);
	}		
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:19,代码来源:RankMaxEnt.java

示例4: print

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public void print (PrintStream out)
{
	final Alphabet dict = getAlphabet();
	final LabelAlphabet labelDict = getLabelAlphabet();

	int numFeatures = dict.size() + 1;
	int numLabels = labelDict.size();

	// Include the feature weights according to each label
	for (int li = 0; li < numLabels; li++) {
		out.println ("FEATURES FOR CLASS "+labelDict.lookupObject (li));
		out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex]);
		for (int i = 0; i < defaultFeatureIndex; i++) {
			Object name = dict.lookupObject (i);
			double weight = parameters [li*numFeatures + i];
			out.println (" "+name+" "+weight);
		}
	}
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:20,代码来源:MaxEnt.java

示例5: print

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
@Override
public void print(PrintWriter out) {
	final Alphabet dict = getAlphabet();
	final LabelAlphabet labelDict = getLabelAlphabet();

	int numFeatures = dict.size() + 1;
	int numLabels = labelDict.size();

	// Include the feature weights according to each label
	for (int li = 0; li < numLabels; li++) {
		out.println ("FEATURES FOR CLASS "+labelDict.lookupObject (li));
		out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex]);
		for (int i = 0; i < defaultFeatureIndex; i++) {
			Object name = dict.lookupObject (i);
			double weight = parameters [li*numFeatures + i];
			out.println (" "+name+" "+weight);
		}
	}
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:20,代码来源:MaxEnt.java

示例6: printExcel

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public void printExcel (String directory, String fileName) throws FileNotFoundException
{
	File parentDir = new File(directory);
	if (!parentDir.exists())
		parentDir.mkdirs();
	
	final Alphabet dict = getAlphabet();
	final LabelAlphabet labelDict = getLabelAlphabet();

	int numFeatures = dict.size() + 1;
	int numLabels = labelDict.size();

	// Include the feature weights according to each label
	for (int li = 0; li < numLabels; li++) {
		File outputFile = new File(directory+labelDict.lookupObject (li)+fileName);
		PrintStream out = new PrintStream (outputFile);
		out.println (labelDict.lookupObject (li)+",FeatureName,FeatureWeight,Default Parameters :,"+parameters [li*numFeatures + defaultFeatureIndex]);

		for (int i = 0; i < defaultFeatureIndex; i++) {
			Object name = dict.lookupObject (i);
			double weight = parameters [li*numFeatures + i];
			out.println ((i+1)+","+name+","+weight);
		}
		out.close();
	}
}
 
开发者ID:shalomeir,项目名称:tctm,代码行数:27,代码来源:MaxEnt.java

示例7: printExcelOne

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public void printExcelOne (String fileName) throws FileNotFoundException
{
	
	final Alphabet dict = getAlphabet();
	final LabelAlphabet labelDict = getLabelAlphabet();

	int numFeatures = dict.size() + 1;
	int numLabels = labelDict.size();

	File outputFile = new File(fileName);
	PrintStream out = new PrintStream (outputFile);
	out.println ("TopicNo,F_No,FeatureName,FeatureWeight,Topic Default Parameter");

	// Include the feature weights according to each label
	for (int li = 0; li < numLabels; li++) {
		for (int i = 0; i < defaultFeatureIndex; i++) {
			Object name = dict.lookupObject (i);
			double weight = parameters [li*numFeatures + i];
			out.println (labelDict.lookupObject (li)+","+(i+1)+","+name+","+weight+","+parameters [li*numFeatures + defaultFeatureIndex]);
		}

	}
	out.close();
}
 
开发者ID:shalomeir,项目名称:tctm,代码行数:25,代码来源:MaxEnt.java

示例8: Variable

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public Variable (Universe universe, LabelAlphabet outs)
{
  this.universe = universe;
  this.outcomes = outs;
  if (outs.size() < 1) {
    throw new IllegalArgumentException
      ("Attempt to create variable with "+outs.size()+" outcomes.");
  }
  setName ();
  index = universe.add (this);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:12,代码来源:Variable.java

示例9: ROCData

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
/**
 * Constructs a new object
 * 
 * @param thresholds        Array of thresholds to track counts for
 * @param labelAlphabet     Label alphabet for instances in {@link Trial}
 */
public ROCData(double[] thresholds, final LabelAlphabet labelAlphabet) {
    // ensure that thresholds are sorted
    Arrays.sort(thresholds);
    this.counts = new int[labelAlphabet.size()][thresholds.length][4];
    this.labelAlphabet = labelAlphabet;
    this.thresholds = thresholds;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:14,代码来源:ROCData.java

示例10: determineFieldNames

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
private static String[] determineFieldNames (LabelAlphabet dict)
{
  List l = new ArrayList ();
  for (int i = 0; i < dict.size (); i++) {
    String lname = dict.lookupLabel (i).toString ();
    if (!lname.startsWith ("B-") && !lname.startsWith ("I-")) {
      l.add (lname);
    }
  }
  return (String[]) l.toArray (new String [l.size ()]);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:12,代码来源:DocumentViewer.java

示例11: eval

import cc.mallet.types.LabelAlphabet; //导入方法依赖的package包/类
public double[] eval(String[] features) {
  Alphabet dataAlphabet = classifer.getAlphabet();

  List<Integer> malletFeatureList = new ArrayList<>(features.length);

  for (String feature : features) {
    int featureId = dataAlphabet.lookupIndex(feature);
    if (featureId != -1) {
      malletFeatureList.add(featureId);
    }
  }

  int malletFeatures[] = new int[malletFeatureList.size()];
  for (int i = 0; i < malletFeatureList.size(); i++) {
    malletFeatures[i] = malletFeatureList.get(i);
  }

  FeatureVector fv = new FeatureVector(classifer.getAlphabet(),
      malletFeatures);
  Instance instance = new Instance(fv, null, null, null);

  Classification result = classifer.classify(instance);

  LabelVector labeling = result.getLabelVector();

  LabelAlphabet targetAlphabet = classifer.getLabelAlphabet();

  double outcomes[] = new double[targetAlphabet.size()];
  for (int i = 0; i < outcomes.length; i++) {

    Label label = targetAlphabet.lookupLabel(i);

    int rank = labeling.getRank(label);
    outcomes[i] = labeling.getValueAtRank(rank);
  }

  return outcomes;
}
 
开发者ID:kottmann,项目名称:opennlp-mallet-addon,代码行数:39,代码来源:ClassifierModel.java


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