Package com.jgaap.util

Examples of com.jgaap.util.EventSet


    EventDriver eventDriver = new VowelMNLetterWordEventDriver();
    eventDriver.setParameter("M", 2);
    eventDriver.setParameter("N", 3);

    EventSet sampleEventSet = eventDriver.createEventSet(text.toCharArray());
    EventSet expectedEventSet = new EventSet();
    Vector<Event> tmp = new Vector<Event>();

    tmp.add(new Event("aa", eventDriver));
    tmp.add(new Event("ee", eventDriver));
    tmp.add(new Event("ii", eventDriver));
    tmp.add(new Event("oo", eventDriver));
    tmp.add(new Event("uu", eventDriver));
    tmp.add(new Event("yy", eventDriver));
    tmp.add(new Event("aaa", eventDriver));
    tmp.add(new Event("eee", eventDriver));
    tmp.add(new Event("iii", eventDriver));
    tmp.add(new Event("ooo", eventDriver));
    tmp.add(new Event("uuu", eventDriver));
    tmp.add(new Event("yyy", eventDriver));
    tmp.add(new Event("AA", eventDriver));
    tmp.add(new Event("EE", eventDriver));
    tmp.add(new Event("II", eventDriver));
    tmp.add(new Event("OO", eventDriver));
    tmp.add(new Event("UU", eventDriver));
    tmp.add(new Event("YY", eventDriver));
    tmp.add(new Event("AAA", eventDriver));
    tmp.add(new Event("EEE", eventDriver));
    tmp.add(new Event("III", eventDriver));
    tmp.add(new Event("OOO", eventDriver));
    tmp.add(new Event("UUU", eventDriver));
    tmp.add(new Event("YYY", eventDriver));


    expectedEventSet.addEvents(tmp);
    System.out.println(sampleEventSet.toString());
    System.out.println(expectedEventSet.toString());
    assertTrue(expectedEventSet.equals(sampleEventSet));
  }
View Full Code Here


  /**
   * Test method for {@link com.jgaap.distances.ManhattanDistance#distance(com.jgaap.util.EventSet, com.jgaap.util.EventSet)}.
   */
  @Test
  public void testDistance() {
    EventSet es1 = new EventSet();
    EventSet es2 = new EventSet();
    Vector<Event> test1 = new Vector<Event>();
    test1.add(new Event("The", null));
    test1.add(new Event("quick", null));
    test1.add(new Event("brown", null));
    test1.add(new Event("fox", null));
    test1.add(new Event("jumps", null));
    test1.add(new Event("over", null));
    test1.add(new Event("the", null));
    test1.add(new Event("lazy", null));
    test1.add(new Event("dog", null));
    test1.add(new Event(".", null));
    es1.addEvents(test1);
    es2.addEvents(test1);
    assertTrue(new ManhattanDistance().distance(new EventMap(es1), new EventMap(es2)) == 0);
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("3", null));
    test2.add(new Event("..", null));
    test2.add(new Event("1", null));
    test2.add(new Event("4", null));
    test2.add(new Event("11", null));
    test2.add(new Event("5", null));
    test2.add(new Event("2", null));
    test2.add(new Event("6", null));
    test2.add(new Event("55", null));
    test2.add(new Event("33", null));
    es2 = new EventSet();
    es2.addEvents(test2);
    double result = new ManhattanDistance().distance(new EventMap(es1), new EventMap(es2));
    assertTrue(DistanceTestHelper.inRange(result, 2.0, 0.0000000001));
  }
View Full Code Here

      return false;
    }

    @Override
    public EventSet createEventSet(char[] text) {
        EventSet es = new EventSet();

        // again, use logging facilities when they exist
        //System.out.println(ds.getDocument(0).getAuthor());
        //for (int i = 0; i < ds.documentCount(); i++) {

            // again, use logging facilities when they exist
      // System.out.println("--- Document #" + i + " --- ");
      // System.out.println(ds.getDocument(i).stringify());

            es.addEvent(new Event(new String(text), this));
        //}

        return es;
    }
View Full Code Here

    String text = (
"a aah Aaron aback abacus abandon abandoned zones zoning zoo " +
"zoologist zoology zoom zooming zooms zucchini Zurich");

    EventDriver eventDriver = new TruncatedNamingTimeEventDriver();
    EventSet sampleEventSet = eventDriver.createEventSet(text.toCharArray());
    EventSet expectedEventSet = new NumericEventSet();
    Vector<Event> tmp = new Vector<Event>();

    tmp.add(new Event("66", eventDriver));
    tmp.add(new Event("64", eventDriver));
    tmp.add(new Event("68", eventDriver));
    tmp.add(new Event("59", eventDriver));
    tmp.add(new Event("79", eventDriver));
    tmp.add(new Event("62", eventDriver));
    tmp.add(new Event("63", eventDriver));
    tmp.add(new Event("59", eventDriver));
    tmp.add(new Event("69", eventDriver));
    tmp.add(new Event("66", eventDriver));
    tmp.add(new Event("73", eventDriver));
    tmp.add(new Event("68", eventDriver));
    tmp.add(new Event("63", eventDriver));
    tmp.add(new Event("67", eventDriver));
    tmp.add(new Event("61", eventDriver));
    tmp.add(new Event("75", eventDriver));
    tmp.add(new Event("82", eventDriver));

    expectedEventSet.addEvents(tmp);

System.out.println("Expected is " + expectedEventSet.toString());
System.out.println("Actual is " + sampleEventSet.toString());
    assertTrue(expectedEventSet.equals(sampleEventSet));
  }
View Full Code Here

    return API.getInstance().getLanguage().getLanguage().equalsIgnoreCase("English");
  }

  @Override
  public EventSet createEventSet(char[] text) {
    EventSet preprocessEventSet = super.createEventSet(text);
    EventSet eventSet = new EventSet();
    for (Event event : preprocessEventSet) {
      if (translationTable.containsKey(event.toString()))
        eventSet.addEvent(new Event(translationTable.get(event.toString()), this));
      else
        eventSet.addEvent(event);
    }
    return eventSet;
  }
View Full Code Here

  /**
   * Test method for {@link com.jgaap.distances.NominalKSDistance#distance(com.jgaap.util.EventSet, com.jgaap.util.EventSet)}.
   */
  @Test
  public void testDistance() {
    EventSet es1 = new EventSet();
    EventSet es2 = new EventSet();
    Vector<Event> test1 = new Vector<Event>();
    test1.add(new Event("The", null));
    test1.add(new Event("quick", null));
    test1.add(new Event("brown", null));
    test1.add(new Event("fox", null));
    test1.add(new Event("jumps", null));
    test1.add(new Event("over", null));
    test1.add(new Event("the", null));
    test1.add(new Event("lazy", null));
    test1.add(new Event("dog", null));
    test1.add(new Event(".", null));
    es1.addEvents(test1);
    es2.addEvents(test1);
   
    assertTrue(new NominalKSDistance().distance(new EventMap(es1), new EventMap(es2)) == 0.00);
   
    Vector<Event> test2 = new Vector<Event>();//set with the same number of elements, only one repeats and none are the same as in test1
    test2.add(new Event("33", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("8", null));
    test2.add(new Event("44", null));
    test2.add(new Event("7", null));
    test2.add(new Event("33", null));
    test2.add(new Event("10", null));
    test2.add(new Event("2", null));
    test2.add(new Event("..", null));
    es2 = new EventSet();
    es2.addEvents(test2);
    double result = new NominalKSDistance().distance(new EventMap(es1), new EventMap(es2));
    assertTrue(DistanceTestHelper.inRange(result, 1.00, 0.0000000001));
  }
View Full Code Here

  }
*/
  @Test
  public void testDistance()
      throws DistanceCalculationException {
    EventSet set1 = new EventSet();
    EventSet set2 = new EventSet();
    Vector<Event> test1 = new Vector<Event>();
    test1.add(new Event("one", null));
    test1.add(new Event("two", null));
    test1.add(new Event("three", null));
    test1.add(new Event("four", null));
    test1.add(new Event("five", null));
    test1.add(new Event("six", null));
    test1.add(new Event("seven", null));
    test1.add(new Event("eight", null));
    test1.add(new Event("nine", null));
    test1.add(new Event("ten", null));     
    set1.addEvents(test1);
    set2.addEvents(test1);
    double result = new BrayCurtisDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 0.0, 0.0000000001));
   
   
    set2 = new EventSet();
    Vector<Event> test2 = new Vector<Event>();
    test2.add(new Event("1", null));
    test2.add(new Event("2", null));
    test2.add(new Event("3", null));
    test2.add(new Event("4", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("7", null));
    test2.add(new Event("8", null));
    test2.add(new Event("9", null));
    test2.add(new Event("10", null));
    set2.addEvents(test2);
    result = new BrayCurtisDistance().distance(new EventMap(set1), new EventMap(set2));
    assertTrue(DistanceTestHelper.inRange(result, 1.0, 0.0000000001));
  }
View Full Code Here

    EventDriver eventDriver = new MNLetterWordEventDriver();
    eventDriver.setParameter("M", 2);
    eventDriver.setParameter("N", 3);
   
    EventSet sampleEventSet = eventDriver.createEventSet(text.toCharArray());
    EventSet expectedEventSet = new EventSet();
    Vector<Event> tmp = new Vector<Event>();

    tmp.add(new Event("bb", eventDriver));
    tmp.add(new Event("ccc", eventDriver));
    tmp.add(new Event("22", eventDriver));
    tmp.add(new Event("333", eventDriver));
    tmp.add(new Event("@@", eventDriver));
    tmp.add(new Event("###", eventDriver));
    tmp.add(new Event("BB", eventDriver));
    tmp.add(new Event("CCC", eventDriver));


    expectedEventSet.addEvents(tmp);
    assertTrue(expectedEventSet.equals(sampleEventSet));
  }
View Full Code Here

           "numerical sprites elucidate\n"+
           "for me the lexicons full weight\n"+
           "if nature gain who can complain\n"+
           "tho dr johnson fulminate");
    NullEventDriver eventDriver = new NullEventDriver();
       EventSet sampleEventSet = eventDriver.createEventSet(text.toCharArray());
       EventSet expectedEventSet = new EventSet();
       Vector<Event> tmp = new Vector<Event>();
       tmp.add(new Event("sir I send a rhyme excelling\n"+
           "in sacred truth and rigid spelling\n"+
           "numerical sprites elucidate\n"+
           "for me the lexicons full weight\n"+
           "if nature gain who can complain\n"+
                 "tho dr johnson fulminate", eventDriver));
       expectedEventSet.addEvents(tmp);
       assertTrue(expectedEventSet.equals(sampleEventSet));

       /*null case would be covered by the spaces in the above test*/
    }
View Full Code Here

  /**
   * Test method for {@link com.jgaap.distances.KendallCorrelationDistance#distance(com.jgaap.util.EventSet, com.jgaap.util.EventSet)}.
   */
  @Test
  public void testDistance() {
    EventSet es1 = new EventSet();
    EventSet es2 = new EventSet();
    Vector<Event> test1 = new Vector<Event>();
    test1.add(new Event("alpha", null));
    test1.add(new Event("alpha", null));
    test1.add(new Event("alpha", null));
    test1.add(new Event("alpha", null));
    test1.add(new Event("beta", null));
    test1.add(new Event("beta", null));
    test1.add(new Event("beta", null));
    test1.add(new Event("gamma", null));
    test1.add(new Event("gamma", null));
    test1.add(new Event("delta", null));
    es1.addEvents(test1);
    es2.addEvents(test1);
    assertTrue(new KendallCorrelationDistance().distance(new EventMap(es1), new EventMap(es2)) == 0);

    es1=new EventSet();
    es2=new EventSet();
    test1 = new Vector<Event>();
    Vector<Event> test2 = new Vector<Event>();
    test1.add(new Event("A", null));
    test1.add(new Event("A", null));
    test1.add(new Event("A", null));
    test1.add(new Event("A", null));
    test1.add(new Event("A", null));
    test1.add(new Event("B", null));
    test1.add(new Event("B", null));
    test1.add(new Event("B", null));
    test1.add(new Event("B", null));
    test1.add(new Event("C", null));
    test1.add(new Event("C", null));
    test1.add(new Event("C", null));
    test1.add(new Event("D", null));
    test1.add(new Event("D", null));
    test1.add(new Event("E", null));

    test2.add(new Event("A", null));
    test2.add(new Event("A", null));
    test2.add(new Event("A", null));
    test2.add(new Event("B", null));
    test2.add(new Event("C", null));
    test2.add(new Event("C", null));
    test2.add(new Event("C", null));
    test2.add(new Event("C", null));
    test2.add(new Event("D", null));
    test2.add(new Event("D", null));
    test2.add(new Event("D", null));
    test2.add(new Event("D", null));
    test2.add(new Event("D", null));
    test2.add(new Event("E", null));
    test2.add(new Event("E", null));

    es1.addEvents(test1);
    es2.addEvents(test2);
    double result = new KendallCorrelationDistance().distance(new EventMap(es1), new EventMap(es2));
    //System.out.println(result);
    assertTrue(DistanceTestHelper.inRange(result, 1.2, 0.0000000001));

    es1=new EventSet();
    es2=new EventSet();
    test1 = new Vector<Event>();
    test2 = new Vector<Event>();

    test1.add(new Event("A", null));
    test1.add(new Event("A", null));
    test1.add(new Event("A", null));
    test1.add(new Event("B", null));
    test1.add(new Event("B", null));
    test1.add(new Event("C", null));

    test2.add(new Event("C", null));
    test2.add(new Event("C", null));
    test2.add(new Event("C", null));
    test2.add(new Event("B", null));
    test2.add(new Event("B", null));
    test2.add(new Event("A", null));

    es1.addEvents(test1);
    es2.addEvents(test2);
    result = new KendallCorrelationDistance().distance(new EventMap(es1), new EventMap(es2));
    //System.out.println(result);
    assertTrue(DistanceTestHelper.inRange(result, 2.0, 0.0000000001));
  }
View Full Code Here

TOP

Related Classes of com.jgaap.util.EventSet

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.