Package cc.mallet.types

Examples of cc.mallet.types.FeatureVector.numLocations()


      FeatureVector features = (FeatureVector) instance.getData();
      assert (features.getAlphabet() == alphabet);

      boolean hasNaN = false;

      for (int i = 0; i < features.numLocations(); i++) {
        if (Double.isNaN(features.valueAtLocation(i))) {
          logger.info("NaN for feature " + alphabet.lookupObject(features.indexAtLocation(i)).toString());
          hasNaN = true;
        }
      }
View Full Code Here


     
      double digammaDifferenceForSums =
        Dirichlet.digamma(sumScores + totalLength) -
        Dirichlet.digamma(sumScores);
     
      for (int loc = 0; loc < features.numLocations(); loc++) {
        int index = features.indexAtLocation(loc);
        double value = features.valueAtLocation(loc);
                   
        if (value == 0.0) { continue; }
View Full Code Here

    BitSet bitSet = new BitSet(data.size());
    for (Instance instance : data) {
      FeatureVectorSequence fvs = (FeatureVectorSequence)instance.getData();
      for (int ip = 0; ip < fvs.size(); ip++) {
        fv = fvs.get(ip);
        for (int loc = 0; loc < fv.numLocations(); loc++) {
          fi = fv.indexAtLocation(loc);
          if (constraints.containsKey(fi)) {
            constraints.get(fi).count += 1;
            bitSet.set(ii);
          }
View Full Code Here

      gammas = lattice.getGammas();
      for (int ip = 0; ip < fvs.size(); ++ip) {
        cache.resetQuick();
        FeatureVector fv = fvs.getFeatureVector(ip);
        int fi;
        for (int loc = 0; loc < fv.numLocations(); loc++) {
          fi = fv.indexAtLocation(loc);
          // binary constraint features
          if (constraints.containsKey(fi)) {
            cache.add(fi);
          }
View Full Code Here

    t.setFeatureValue ("containsVowel", 1);
    t.setFeatureValue ("in /usr/dict/words", 0);

    Alphabet dict = new Alphabet();
    FeatureVector fv = t.toFeatureVector (dict, false);
    assertTrue (fv.numLocations() == 2);
    assertTrue (fv.value (dict.lookupIndex("length")) == 3);
  }

  public void testTwo ()
  {
View Full Code Here

            if (valsj != null) {
              comparisons++;
              for (int ii = 0; ii < valsi.numLocations(); ii++) {
                String si = (String) valueAlph
                    .lookupObject(valsi.indexAtLocation(ii));
                for (int jj = 0; jj < valsj.numLocations(); jj++) {
                  String sj = (String) valueAlph
                      .lookupObject(valsj
                          .indexAtLocation(jj));
                  if (Strings.levenshteinDistance(si, sj) < approxMatchThreshold) {
                    matches++;
View Full Code Here

              comparisons++;
              for (int ii = 0; ii < valsi.numLocations(); ii++) {
                String si = (String) valueAlph
                .lookupObject(valsi.indexAtLocation(ii));
                if (si.length() < 2) break;
                for (int jj = 0; jj < valsj.numLocations(); jj++) {
                  String sj = (String) valueAlph
                      .lookupObject(valsj
                          .indexAtLocation(jj));
                  if (sj.length() > 2 && (si.contains(si) || sj.contains(si))) {
                    matches++;
View Full Code Here

      // loop through all instances
      for (int ii = 0; ii < trainingList.size(); ii++) {
        Instance inst = trainingList.get(ii);
        Labeling labeling = inst.getLabeling ();
        FeatureVector fv = (FeatureVector) inst.getData();
        int fvisize = fv.numLocations();
        int correctIndex = labeling.getBestIndex();
        Arrays.fill(results, 0);

        // compute dot(x, wi) for each class i
        for(int lpos = 0; lpos < numLabels; lpos++) {
View Full Code Here

            FeatureVector input = (FeatureVector)ti.getInput();
            int index = ti.getIndex();
            int nwi = source.weightsIndices[index].length;
            for (int wi = 0; wi < nwi; wi++) {
              int weightsIndex = source.weightsIndices[index][wi];
              for (int i = 0; i < input.numLocations(); i++) {
                int featureIndex = input.indexAtLocation(i);
                if ((globalFeatureSelection == null || globalFeatureSelection.contains(featureIndex))
                    && (featureSelections == null
                        || featureSelections[weightsIndex] == null
                        || featureSelections[weightsIndex].contains(featureIndex)))
View Full Code Here

            FeatureVector input = (FeatureVector)ti.getInput();
            int index = ti.getIndex();
            int nwi = source.weightsIndices[index].length;
            for (int wi = 0; wi < nwi; wi++) {
              int weightsIndex = source.weightsIndices[index][wi];
              for (int i = 0; i < input.numLocations(); i++) {
                int featureIndex = input.indexAtLocation(i);
                if ((globalFeatureSelection == null || globalFeatureSelection.contains(featureIndex))
                    && (featureSelections == null
                        || featureSelections[weightsIndex] == null
                        || featureSelections[weightsIndex].contains(featureIndex)))
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.