⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testassignmentiterator.java

📁 这是一个matlab的java实现。里面有许多内容。请大家慢慢捉摸。
💻 JAVA
字号:
/* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept.   This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit).   http://www.cs.umass.edu/~mccallum/mallet   This software is provided under the terms of the Common Public License,   version 1.0, as published by http://www.opensource.org.  For further   information, see the file `LICENSE' included with this distribution. */package edu.umass.cs.mallet.grmm.test;import junit.framework.TestCase;import junit.framework.Test;import junit.framework.TestSuite;import edu.umass.cs.mallet.grmm.Variable;import edu.umass.cs.mallet.grmm.MultinomialPotential;import edu.umass.cs.mallet.grmm.AssignmentIterator;import edu.umass.cs.mallet.grmm.Assignment;/** * Created: Aug 11, 2004 * * @author <A HREF="mailto:casutton@cs.umass.edu>casutton@cs.umass.edu</A> * @version $Id: TestAssignmentIterator.java,v 1.1 2004/08/11 20:07:15 casutton Exp $ */public class TestAssignmentIterator extends TestCase {  /**   * Constructs a test case with the given name.   */  public TestAssignmentIterator (String name)  {    super (name);  }  public void testSum ()  {    Variable vars [] = {      new Variable (2),      new Variable (2),    };    double[] probs = { 0.1, 10.3, 17, 0.5 };    MultinomialPotential ptl = new MultinomialPotential (vars, probs);    AssignmentIterator it = ptl.assignmentIterator ();    double total = 0;    while (it.hasNext ()) {      total += ptl.phi (it);      it.advance ();    }    assertEquals (27.9, total, 0.01);  }  public void testLazyAssignment ()  {    Variable vars [] = {      new Variable (2),      new Variable (2),    };    double[] probs = { 0.1, 10.3, 17, 0.5 };    MultinomialPotential ptl = new MultinomialPotential (vars, probs);    AssignmentIterator it = ptl.assignmentIterator ();    it.advance ();    it.advance ();    Assignment assn = it.assignment ();    assertEquals (2, assn.size ());       assertEquals (1, assn.get (vars [0]));    assertEquals (0, assn.get (vars [1]));  }  public static Test suite()  {    return new TestSuite(TestAssignmentIterator.class);  }  public static void main(String[] args) throws Exception  {    TestSuite theSuite;    if (args.length > 0) {      theSuite = new TestSuite();      for (int i = 0; i < args.length; i++) {        theSuite.addTest(new TestAssignmentIterator(args[i]));      }    } else {      theSuite = (TestSuite) suite();    }    junit.textui.TestRunner.run(theSuite);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -