InteractionValueEncoder extends FeatureVectorEncoder { @Override public void addToVector(String originalForm, double w, Vector data) { throw new UnsupportedOperationException("addToVector is not supported for InteractionVectorEncoder"); } 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);  }
@Test public void testAddToVector() { WordValueEncoder wv = new StaticWordValueEncoder("word"); ContinuousValueEncoder cv = new ContinuousValueEncoder("cont"); InteractionValueEncoder enc = new InteractionValueEncoder("interactions", wv, cv); Vector v1 = new DenseVector(200); enc.addInteractionToVector("a","1.0",1.0, v1); int k = enc.getProbes(); assertEquals((float) k, v1.norm(1), 0); assertEquals(1.0, v1.maxValue(), 0); enc.addInteractionToVector("a","1.0",1.0,v1); assertEquals((float) k*2, v1.norm(1), 0); assertEquals(2.0, v1.maxValue(), 0); Vector v2 = new DenseVector(20000); enc.addInteractionToVector("a","1.0",1.0,v2); wv.addToVector("a", v2); cv.addToVector("1.0", v2); k = enc.getProbes(); assertEquals((float) (k + wv.getProbes()+cv.getProbes()), v2.norm(1), 1.0e-3); }