Examples of HashBag


Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
    public void testUnmodifiableBag() {
        Bag bag = BagUtils.unmodifiableBag(new HashBag());
        assertTrue("Returned object should be an UnmodifiableBag.",
            bag instanceof UnmodifiableBag);
        try {
            bag = BagUtils.unmodifiableBag(null);
            fail("Expecting IllegalArgumentException for null bag.");
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
    public void testPredicatedBag() {
        Bag bag = BagUtils.predicatedBag(new HashBag(), truePredicate);
        assertTrue("Returned object should be a PredicatedBag.",
            bag instanceof PredicatedBag);
        try {
            bag = BagUtils.predicatedBag(null,truePredicate);
            fail("Expecting IllegalArgumentException for null bag.");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            bag = BagUtils.predicatedBag(new HashBag(), null);
            fail("Expecting IllegalArgumentException for null predicate.");
        } catch (IllegalArgumentException ex) {
            // expected
       
    }
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
    public void testTypedBag() {
        Bag bag = BagUtils.typedBag(new HashBag(), stringClass);     
        assertTrue("Returned object should be a TypedBag.",
            bag instanceof PredicatedBag);
        try {
            bag = BagUtils.typedBag(null, stringClass);
            fail("Expecting IllegalArgumentException for null bag.");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            bag = BagUtils.typedBag(new HashBag(), null);
            fail("Expecting IllegalArgumentException for null type.");
        } catch (IllegalArgumentException ex) {
            // expected
       
    }
View Full Code Here

Examples of org.apache.commons.collections.bag.HashBag

            // expected
       
    }
   
     public void testTransformedBag() {
        Bag bag = BagUtils.transformedBag(new HashBag(), nopTransformer);     
        assertTrue("Returned object should be an TransformedBag.",
            bag instanceof TransformedBag);
        try {
            bag = BagUtils.transformedBag(null, nopTransformer);     
            fail("Expecting IllegalArgumentException for null bag.");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            bag = BagUtils.transformedBag(new HashBag(), null)
            fail("Expecting IllegalArgumentException for null transformer.");
        } catch (IllegalArgumentException ex) {
            // expected
       
    }
View Full Code Here

Examples of org.apache.commons.collections15.bag.HashBag

        assertEquals(0, CollectionUtils.cardinality("B", set));
        assertEquals(1, CollectionUtils.cardinality("C", set));
        assertEquals(0, CollectionUtils.cardinality("D", set));
        assertEquals(1, CollectionUtils.cardinality("E", set));

        Bag bag = new HashBag();
        bag.add("A", 3);
        bag.add("C");
        bag.add("E");
        bag.add("E");
        assertEquals(3, CollectionUtils.cardinality("A", bag));
        assertEquals(0, CollectionUtils.cardinality("B", bag));
        assertEquals(1, CollectionUtils.cardinality("C", bag));
        assertEquals(0, CollectionUtils.cardinality("D", bag));
        assertEquals(2, CollectionUtils.cardinality("E", bag));
View Full Code Here

Examples of org.apache.commons.collections15.bag.HashBag

        // Enumeration, non-existent entry -- "dead" enumerator returned
        test = CollectionUtils.index(enumeration, 3);
        assertTrue(test.equals(enumeration) && !enumeration.hasMoreElements());
       
        // Collection, entry exists
        Bag bag = new HashBag();
        bag.add("element", 1);
        test = CollectionUtils.index(bag, 0);
        assertTrue(test.equals("element"));
       
        // Collection, non-existent entry -- "dead" iterator returned
        test = CollectionUtils.index(bag, 2);
View Full Code Here

Examples of org.apache.commons.collections15.bag.HashBag

            assertTrue(!enumeration.hasMoreElements());
        }

        {
            // Collection, entry exists
            Bag bag = new HashBag();
            bag.add("element", 1);
            assertEquals("element", CollectionUtils.get(bag, 0));
       
            // Collection, non-existent entry
            try {
                CollectionUtils.get(bag, 1);
View Full Code Here

Examples of org.apache.commons.collections4.bag.HashBag

  }

  //loads the files and removes words which occur less than 5 tims
  public void loadProgram() throws FileNotFoundException
  {
    Bag wordBag = new HashBag();

    //Load all the medical files in the directory
    File[] fileList = new File(recordsDir).listFiles();
    for (int i = 0; i<fileList.length; i++) {
      loadFile(fileList[i].toString(), wordBag);
    }

    //dump bag into frequent who appear in 5 or more medical records
    for (Object obj : wordBag.uniqueSet()) {
      if (wordBag.getCount(obj) > 4){
        frequent.add((String)obj);
      }
    }

  }
View Full Code Here

Examples of org.apache.commons.collections4.bag.HashBag



    //put entries in bag to get count
    String entryBuilder;
    Bag <String> bagOfEntries = new <String>HashBag();
    for (ArrayList<String> temp : output)
    {
      entryBuilder = "";
      for (String tempWord : temp)
      {
        String scrap = tempWord + " ";
        entryBuilder += scrap;
      }
      bagOfEntries.add(entryBuilder);
    }

    //make a map with values - count and keys - string and sort by frequency
    Map<String, Integer> frequentWords = new <String, Integer>HashMap();
    for (String pattern : bagOfEntries.uniqueSet()) {
      frequentWords.put(pattern, bagOfEntries.getCount(pattern));
    }
    Map.Entry<String, Integer>[] entries = frequentWords.entrySet().toArray(new Map.Entry[0]);
    Arrays.sort(entries, new Comparator<Map.Entry<String, Integer>>() {
        public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
          return o2.getValue().compareTo(o1.getValue());
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.