Package com.clearnlp.collection.list

Examples of com.clearnlp.collection.list.FloatArrayList


    return true;
  }
 
  public void threads(String[] args) throws Exception
  {
    FloatArrayList fs = new FloatArrayList();
    Random rand = new Random(0);
    int i, n = Integer.parseInt(args[0]), size = 100000000, gap = size / n;
    int[] is = new int[size];
    long st, et;
   
    for (i=0; i<size; i++)
      fs.add(i);
   
    for (i=0; i<size; i++)
      is[i] = rand.nextInt(size);
   
    st = System.currentTimeMillis();
View Full Code Here


    }
  }
 
  void testObjectStream() throws Exception
  {
    FloatArrayList list = new FloatArrayList();
   
    list.add(0);
    list.add(1);
    list.add(2);
 
    System.out.println(Arrays.toString(list.toArray()));
   
    ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("tmp.txt"));
    out.writeObject(list);
    out.close();
   
    ObjectInputStream in = new ObjectInputStream(new FileInputStream("tmp.txt"));
    list = (FloatArrayList)in.readObject();
    in.close();
   
    System.out.println(Arrays.toString(list.toArray()));
  }
View Full Code Here

    m_labels    = new ObjectIntHashMap<String>();
    a_labels    = Lists.newArrayList();
    n_labels    = 0;
    m_features  = Maps.newHashMap();
    n_features  = 1;
    f_weights   = new FloatArrayList();   
  }
View Full Code Here

    f_weights   = new FloatArrayList();   
  }
 
  public void trimFeatures(Logger log, float threshold)
  {
    FloatArrayList tWeights = new FloatArrayList(f_weights.size());
    IntIntOpenHashMap map = new IntIntOpenHashMap();
    ObjectIntHashMap<String> m;
    int i, j, tFeatures = 1;
    boolean trim;
    String s;
   
    log.info("Trimming: ");
   
    // bias
    for (j=0; j<n_labels; j++)
      tWeights.add(f_weights.get(j));
   
    // rest
    for (i=1; i<n_features; i++)
    {
      trim = true;
     
      for (j=0; j<n_labels; j++)
      {
        if (Math.abs(f_weights.get(i*n_labels+j)) > threshold)
        {
          trim = false;
          break;
        }
      }
     
      if (!trim)
      {
        map.put(i, tFeatures++);
       
        for (j=0; j<n_labels; j++)
          tWeights.add(f_weights.get(i*n_labels+j));       
      }
    }
   
    log.info(String.format("%d -> %d\n", n_features, tFeatures));
    tWeights.trimToSize();
   
    // map
    for (String type : Lists.newArrayList(m_features.keySet()))
    {
      m = m_features.get(type);
View Full Code Here

 
  protected ObjectDoublePair<List<String>> developOnline(String[] developFiles, JointReader reader, AbstractOnlineStatisticalComponent<? extends AbstractState> component, StringModelAD model, AbstractAlgorithm algorithm, double bootstrapScore, byte flag) throws Exception
  {
    boolean prepareBootstrap = bootstrapScore > 0;
    List<String> currOutput, bestOutput = null;
    FloatArrayList bestWeights = null;
    double currScore, bestScore = 0;
    AbstractEval eval;
    int iter;
   
    for (iter=1; true; iter++)
View Full Code Here

   
    int[] indices = UTArray.range(s_model.getInstanceSize());
    Random rand = new Random(randomSeed);
    AbstractEval eval = new POSEval();
    double prevScore, currScore = 0;
    FloatArrayList prevWeights;
    String[] goldLabels;
    int iter = 1;
   
    do
    {
View Full Code Here

    }
  }
 
  void testObjectStream() throws Exception
  {
    FloatArrayList list = new FloatArrayList();
   
    list.add(0);
    list.add(1);
    list.add(2);
 
    System.out.println(Arrays.toString(list.toArray()));
   
    ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("tmp.txt"));
    out.writeObject(list);
    out.close();
   
    ObjectInputStream in = new ObjectInputStream(new FileInputStream("tmp.txt"));
    list = (FloatArrayList)in.readObject();
    in.close();
   
    System.out.println(Arrays.toString(list.toArray()));
  }
View Full Code Here

    m_labels    = new ObjectIntHashMap<String>();
    a_labels    = Lists.newArrayList();
    n_labels    = 0;
    m_features  = Maps.newHashMap();
    n_features  = 1;
    f_weights   = new FloatArrayList();
    i_collector = new InstanceCollector();
  }
View Full Code Here

TOP

Related Classes of com.clearnlp.collection.list.FloatArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.