~ubuntu-branches/ubuntu/oneiric/weka/oneiric

« back to all changes in this revision

Viewing changes to weka/core/FindWithCapabilities.java

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner, Soeren Sonnenburg, Torsten Werner
  • Date: 2008-08-10 21:27:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080810212705-tr8etpnkdx2ziktp
Tags: 3.5.8-1
[ Soeren Sonnenburg ]
* Bump Standards Version to 3.8.0.
* Remove references to non-free Java in debian/copyright.

[ Torsten Werner ]
* new upstream release
* Switch to openjdk-6.
* Move package to main.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
 * <pre> -relational-class
73
73
 *  Must handle relational classes.</pre>
74
74
 * 
 
75
 * <pre> -missing-class-values
 
76
 *  Must handle missing class values.</pre>
 
77
 * 
75
78
 * <pre> -no-class
76
79
 *  Doesn't need a class.</pre>
77
80
 * 
96
99
 * <pre> -relational-atts
97
100
 *  Must handle relational attributes.</pre>
98
101
 * 
 
102
 * <pre> -missing-att-values
 
103
 *  Must handle missing attribute values.</pre>
 
104
 * 
99
105
 * <pre> -only-multiinstance
100
106
 *  Must handle multi-instance data.</pre>
101
107
 * 
134
140
 <!-- options-end -->
135
141
 * 
136
142
 * @author  fracpete (fracpete at waikato dot ac dot nz)
137
 
 * @version $Revision: 1.3 $
 
143
 * @version $Revision: 1.5 $
138
144
 * @see Capabilities
139
145
 * @see Capabilities.Capability
140
146
 * @see GenericPropertiesCreator
141
147
 */
142
148
public class FindWithCapabilities 
143
 
implements OptionHandler, CapabilitiesHandler {
 
149
implements OptionHandler, CapabilitiesHandler, RevisionHandler {
144
150
 
145
 
  /** the capabilities to look for */
 
151
  /** the capabilities to look for. */
146
152
  protected Capabilities m_Capabilities = new Capabilities(this);
147
153
 
148
 
  /** the capabilities to look for to "not have" */
 
154
  /** the capabilities to look for to "not have". */
149
155
  protected Capabilities m_NotCapabilities = new Capabilities(this);
150
156
 
151
 
  /** the packages to search in */
 
157
  /** the packages to search in. */
152
158
  protected Vector m_Packages = new Vector();
153
159
 
154
 
  /** a capabilities handler to retrieve the capabilities from */
 
160
  /** a capabilities handler to retrieve the capabilities from. */
155
161
  protected CapabilitiesHandler m_Handler = null;
156
162
 
157
 
  /** a file the capabilities can be based on */
 
163
  /** a file the capabilities can be based on. */
158
164
  protected String m_Filename = "";
159
165
 
160
 
  /** the class index, in case the capabilities are based on a file */
 
166
  /** the class index, in case the capabilities are based on a file. */
161
167
  protected SingleIndex m_ClassIndex = new SingleIndex();
162
168
 
163
 
  /** the superclass from the GenericPropertiesCreator to retrieve the packages from */
 
169
  /** the superclass from the GenericPropertiesCreator to retrieve the packages from. */
164
170
  protected String m_Superclass = "";
165
171
 
166
 
  /** whether to use the GenericPropertiesCreator with the superclass */
 
172
  /** whether to use the GenericPropertiesCreator with the superclass. */
167
173
  protected boolean m_GenericPropertiesCreator = false;
168
174
 
169
 
  /** the classes that matched */
 
175
  /** the classes that matched. */
170
176
  protected Vector m_Matches = new Vector();
171
177
 
172
 
  /** the class that didn't match */
 
178
  /** the class that didn't match. */
173
179
  protected Vector m_Misses = new Vector();
174
180
 
175
181
  /**
219
225
        "relational-class", 0, "-relational-class"));
220
226
 
221
227
    result.addElement(new Option(
 
228
        "\tMust handle missing class values.",
 
229
        "missing-class-values", 0, "-missing-class-values"));
 
230
 
 
231
    result.addElement(new Option(
222
232
        "\tDoesn't need a class.",
223
233
        "no-class", 0, "-no-class"));
224
234
 
251
261
        "relational-atts", 0, "-relational-atts"));
252
262
 
253
263
    result.addElement(new Option(
 
264
        "\tMust handle missing attribute values.",
 
265
        "missing-att-values", 0, "-missing-att-values"));
 
266
 
 
267
    result.addElement(new Option(
254
268
        "\tMust handle multi-instance data.",
255
269
        "only-multiinstance", 0, "-only-multiinstance"));
256
270
 
371
385
        enable(Capability.DATE_CLASS);
372
386
      if (Utils.getFlag("relational-class", options))
373
387
        enable(Capability.RELATIONAL_CLASS);
 
388
      if (Utils.getFlag("missing-class-values", options))
 
389
        enable(Capability.MISSING_CLASS_VALUES);
374
390
    }
375
391
    // not allowed
376
392
    if (Utils.getFlag("not-nominal-class", options)) {
391
407
      enableNot(Capability.DATE_CLASS);
392
408
    if (Utils.getFlag("not-relational-class", options))
393
409
      enableNot(Capability.RELATIONAL_CLASS);
 
410
    if (Utils.getFlag("not-relational-class", options))
 
411
      enableNot(Capability.RELATIONAL_CLASS);
 
412
    if (Utils.getFlag("not-missing-class-values", options))
 
413
      enableNot(Capability.MISSING_CLASS_VALUES);
394
414
 
395
415
    // allowed
396
416
    if (Utils.getFlag("nominal-atts", options)) {
411
431
      enable(Capability.DATE_ATTRIBUTES);
412
432
    if (Utils.getFlag("relational-atts", options))
413
433
      enable(Capability.RELATIONAL_ATTRIBUTES);
 
434
    if (Utils.getFlag("missing-att-values", options))
 
435
      enable(Capability.MISSING_VALUES);
414
436
    // not allowed
415
437
    if (Utils.getFlag("not-nominal-atts", options)) {
416
438
      enableNot(Capability.NOMINAL_ATTRIBUTES);
430
452
      enableNot(Capability.DATE_ATTRIBUTES);
431
453
    if (Utils.getFlag("not-relational-atts", options))
432
454
      enableNot(Capability.RELATIONAL_ATTRIBUTES);
 
455
    if (Utils.getFlag("not-missing-att-values", options))
 
456
      enableNot(Capability.MISSING_VALUES);
433
457
 
434
458
    if (Utils.getFlag("only-multiinstance", options))
435
459
      enable(Capability.ONLY_MULTIINSTANCE);
492
516
        result.add("-date-class");
493
517
      if (isEnabled(Capability.RELATIONAL_CLASS))
494
518
        result.add("-relational-class");
 
519
      if (isEnabled(Capability.MISSING_CLASS_VALUES))
 
520
        result.add("-missing-class-values");
495
521
    }
496
522
 
497
523
    if (isEnabled(Capability.UNARY_ATTRIBUTES))
508
534
      result.add("-date-atts");
509
535
    if (isEnabled(Capability.RELATIONAL_ATTRIBUTES))
510
536
      result.add("-relational-atts");
 
537
    if (isEnabled(Capability.MISSING_VALUES))
 
538
      result.add("-missing-att-values");
511
539
 
512
540
    // not allowed
513
541
    if (isEnabledNot(Capability.NO_CLASS))
526
554
      result.add("-not-date-class");
527
555
    if (isEnabledNot(Capability.RELATIONAL_CLASS))
528
556
      result.add("-not-relational-class");
 
557
    if (isEnabledNot(Capability.MISSING_CLASS_VALUES))
 
558
      result.add("-not-missing-class-values");
529
559
 
530
560
    if (isEnabledNot(Capability.UNARY_ATTRIBUTES))
531
561
      result.add("-not-unary-atts");
541
571
      result.add("-not-date-atts");
542
572
    if (isEnabledNot(Capability.RELATIONAL_ATTRIBUTES))
543
573
      result.add("-not-relational-atts");
 
574
    if (isEnabledNot(Capability.MISSING_VALUES))
 
575
      result.add("-not-missing-att-values");
544
576
 
545
577
    if (isEnabled(Capability.ONLY_MULTIINSTANCE))
546
578
      result.add("-only-multi-instance");
575
607
  }
576
608
 
577
609
  /**
578
 
   * sets the Capabilities handler to generate the data for
 
610
   * sets the Capabilities handler to generate the data for.
 
611
   * 
 
612
   * @param value       the handler
579
613
   */
580
614
  public void setHandler(CapabilitiesHandler value) {
581
615
    m_Handler = value;
584
618
 
585
619
  /**
586
620
   * returns the current set CapabilitiesHandler to generate the dataset
587
 
   * for, can be null
 
621
   * for, can be null.
 
622
   * 
 
623
   * @return            the handler
588
624
   */
589
625
  public CapabilitiesHandler getHandler() {
590
626
    return m_Handler;
593
629
  /**
594
630
   * Sets the dataset filename to base the capabilities on. It immediately
595
631
   * loads the dataset and retrieves the capabilities from it.
 
632
   * 
 
633
   * @param value       the filename of the dataset
596
634
   */
597
635
  public void setFilename(String value) {
598
636
    Instances           insts;
614
652
  }
615
653
 
616
654
  /**
617
 
   * returns the current filename for the dataset to base the capabilities on
 
655
   * returns the current filename for the dataset to base the capabilities on.
 
656
   * 
 
657
   * @return            the filename of the dataset
618
658
   */
619
659
  public String getFilename() {
620
660
    return m_Filename;
621
661
  }
622
662
 
623
663
  /**
624
 
   * sets the class index, -1 for none, first and last are also valid
 
664
   * sets the class index, -1 for none, first and last are also valid.
 
665
   * 
 
666
   * @param value       the class index
625
667
   */
626
668
  public void setClassIndex(String value) {
627
669
    if (value.equals("-1"))
631
673
  }
632
674
 
633
675
  /**
634
 
   * returns the current current class index, -1 if no class attribute
 
676
   * returns the current current class index, -1 if no class attribute.
 
677
   * 
 
678
   * @return            the class index
635
679
   */
636
680
  public String getClassIndex() {
637
681
    if (m_ClassIndex == null)
641
685
  }
642
686
 
643
687
  /**
644
 
   * enables the given capability
 
688
   * enables the given capability.
645
689
   * 
646
690
   * @param c           the capability to enable
647
691
   */
650
694
  }
651
695
 
652
696
  /**
653
 
   * whether the given capability is enabled
 
697
   * whether the given capability is enabled.
654
698
   * 
655
699
   * @param c           the capability to enable
656
700
   * @return            true if the capability is enabled
660
704
  }
661
705
 
662
706
  /**
663
 
   * disables the given capability
 
707
   * disables the given capability.
664
708
   * 
665
709
   * @param c           the capability to disable
666
710
   */
669
713
  }
670
714
 
671
715
  /**
672
 
   * enables the given "not to have" capability
 
716
   * enables the given "not to have" capability.
673
717
   * 
674
718
   * @param c           the capability to enable
675
719
   */
678
722
  }
679
723
 
680
724
  /**
681
 
   * whether the given "not to have" capability is enabled
 
725
   * whether the given "not to have" capability is enabled.
682
726
   * 
683
727
   * @param c           the capability to enable
684
728
   * @return            true if the capability is enabled
688
732
  }
689
733
 
690
734
  /**
691
 
   * disables the given "not to have" capability
 
735
   * disables the given "not to have" capability.
692
736
   * 
693
737
   * @param c           the capability to disable
694
738
   */
697
741
  }
698
742
 
699
743
  /**
700
 
   * returns true if the given capability can be handled
 
744
   * returns true if the given capability can be handled.
701
745
   * 
702
746
   * @param c           the capability to check
703
747
   * @return            true if the capability can be handled
745
789
  }
746
790
 
747
791
  /**
748
 
   * returns the matches from the last find call
 
792
   * returns the matches from the last find call.
749
793
   * 
750
794
   * @return            the matching classname from the last find run
751
795
   */
754
798
  }
755
799
 
756
800
  /**
757
 
   * returns the misses from the last find call
 
801
   * returns the misses from the last find call.
758
802
   * 
759
803
   * @return            the classnames that didn't match from the last find run
760
804
   */
763
807
  }
764
808
 
765
809
  /**
766
 
   * returns a list with all the classnames that fit the criteria
 
810
   * returns a list with all the classnames that fit the criteria.
767
811
   * 
768
812
   * @return            contains all classnames that fit the criteria
769
813
   */
840
884
 
841
885
    return m_Matches;
842
886
  }
 
887
  
 
888
  /**
 
889
   * Returns the revision string.
 
890
   * 
 
891
   * @return            the revision
 
892
   */
 
893
  public String getRevision() {
 
894
    return RevisionUtils.extract("$Revision: 1.5 $");
 
895
  }
843
896
 
844
897
  /**
845
898
   * Executes the location of classes with parameters from the commandline.