@Test public void testTraceDictionary() { StaticWordValueEncoder encoder1 = new StaticWordValueEncoder("first"); StaticWordValueEncoder encoder2 = new StaticWordValueEncoder("second"); Map<String, Set<Integer>> traceDictionary = Maps.newHashMap(); InteractionValueEncoder interactions = new InteractionValueEncoder("interactions", encoder1, encoder2); interactions.setProbes(1); interactions.setTraceDictionary(traceDictionary); Vector v = new DenseVector(10); interactions.addInteractionToVector("a", "b", 1, v); assertEquals(1, v.getNumNonZeroElements()); assertEquals(1, traceDictionary.size()); assertEquals("interactions=a:b", getFirst(traceDictionary.keySet(), null)); }
public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } InteractionValueEncoder(String name, FeatureVectorEncoder encoderOne, FeatureVectorEncoder encoderTwo); }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } InteractionValueEncoder(String name, FeatureVectorEncoder encoderOne, FeatureVectorEncoder encoderTwo); @Override void addToVector(String originalForm, double w, Vector data); @Override void addToVector(byte[] originalForm, double w, Vector data); void addInteractionToVector(String original1, String original2, double weight, Vector data); void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data); @Override String asString(String originalForm); }
InteractionValueEncoder extends FeatureVectorEncoder { public void addInteractionToVector(String original1, String original2, double weight, Vector data) { byte[] originalForm1 = bytesForString(original1); byte[] originalForm2 = bytesForString(original2); addInteractionToVector(originalForm1, originalForm2, weight, data); } InteractionValueEncoder(String name, FeatureVectorEncoder encoderOne, FeatureVectorEncoder encoderTwo); @Override void addToVector(String originalForm, double w, Vector data); @Override void addToVector(byte[] originalForm, double w, Vector data); void addInteractionToVector(String original1, String original2, double weight, Vector data); void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data); @Override String asString(String originalForm);  }