From 6ee5db120857236bc318da93dc6ce9f5ff28f26c Mon Sep 17 00:00:00 2001 From: Jean Paul Barddal Date: Thu, 12 May 2016 08:32:40 +1200 Subject: [PATCH] Fix to Attribute Indexing The same attribute, across different concepts, is denoted by different objects. Instances class was updated to perform the indexing by attributes' names. --- .../java/com/yahoo/labs/samoa/instances/Instances.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/moa/src/main/java/com/yahoo/labs/samoa/instances/Instances.java b/moa/src/main/java/com/yahoo/labs/samoa/instances/Instances.java index 91fa85b37..559e3bdfd 100644 --- a/moa/src/main/java/com/yahoo/labs/samoa/instances/Instances.java +++ b/moa/src/main/java/com/yahoo/labs/samoa/instances/Instances.java @@ -59,7 +59,7 @@ public class Instances implements Serializable { /** * A Hash that stores the indices of features. */ - protected HashMap hsAttributesIndices; + protected HashMap hsAttributesIndices; /** * Instantiates a new instances. @@ -564,18 +564,18 @@ protected String stringWithoutHeader() { * @param att, the attribute. */ protected int indexOf(Attribute att) { - return this.hsAttributesIndices.get(att); + return this.hsAttributesIndices.get(att.name()); } /** * Completes the hashset with attributes indices. */ private void computeAttributesIndices() { - this.hsAttributesIndices = new HashMap(); + this.hsAttributesIndices = new HashMap(); // iterates through all existing attributes // and sets an unique identifier for each one of them for (int i = 0; i < this.numAttributes(); i++) { - hsAttributesIndices.put(this.attribute(i), i); + hsAttributesIndices.put(this.attribute(i).name(), i); } }