Package com.jgaap.util

Examples of com.jgaap.util.Event


  @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


            // 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

    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());
View Full Code Here

  @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

  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

  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

   
    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

           "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));
View Full Code Here

  @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);
View Full Code Here

     
      EventSet sampleSet = eventDriver.createEventSet(text.toCharArray());
     
      EventSet expectedSet = new EventSet();
      Vector<Event> tmp = new Vector<Event>();
      tmp.add(new Event("Quick", eventDriver));
      tmp.add(new Event("Brown", eventDriver));
      tmp.add(new Event("Fox", eventDriver));
      tmp.add(new Event("Jumped", eventDriver));
      tmp.add(new Event("Over", eventDriver));
      tmp.add(new Event("Lazy", eventDriver));
      tmp.add(new Event("Dog", eventDriver));

       expectedSet.addEvents(tmp);
      
        assertTrue(expectedSet.equals(sampleSet));
        }
View Full Code Here

TOP

Related Classes of com.jgaap.util.Event

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.