/** * Converts a value into a form that would help a human understand the internals of how the value * is being interpreted. For text-like things, this is likely to be a list of the terms found with * associated weights (if any). * * @param originalForm The original form of the value as a string. * @return A string that a human can read. */ @Override public String asString(String originalForm) { return String.format(Locale.ENGLISH, "%s:%s", getName(), originalForm); }
/** * Converts a value into a form that would help a human understand the internals of how the value * is being interpreted. For text-like things, this is likely to be a list of the terms found with * associated weights (if any). * * @param originalForm The original form of the value as a string. * @return A string that a human can read. */ @Override public String asString(String originalForm) { return String.format(Locale.ENGLISH, "%s:%s", getName(), originalForm); }
/** * Converts a value into a form that would help a human understand the internals of how the value * is being interpreted. For text-like things, this is likely to be a list of the terms found with * associated weights (if any). * * @param originalForm The original form of the value as a string. * @return A string that a human can read. */ @Override public String asString(String originalForm) { return String.format(Locale.ENGLISH, "%s:%s", getName(), originalForm); }
/** * Adds a value to a vector. * * @param originalForm1 The original form of the first value as a byte array. * @param originalForm2 The original form of the second value as a byte array. * @param weight How much to weight this interaction * @param data The vector to which the value should be added. */ public void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data) { String name = getName(); double w = getWeight(originalForm1, originalForm2, weight); for (int i = 0; i < probes(); i++) { Iterable<Integer> jValues = secondEncoder.hashesForProbe(originalForm2, data.size(), name, i % secondEncoder.getProbes()); for (Integer k : firstEncoder.hashesForProbe(originalForm1, data.size(), name, i % firstEncoder.getProbes())) { for (Integer j : jValues) { int n = (k + j) % data.size(); if (isTraceEnabled()) { trace(String.format("%s:%s", new String(originalForm1, Charsets.UTF_8), new String(originalForm2, Charsets.UTF_8)), n); } data.set(n, data.get(n) + w); } } } }
/** * Adds a value to a vector. * * @param originalForm1 The original form of the first value as a byte array. * @param originalForm2 The original form of the second value as a byte array. * @param weight How much to weight this interaction * @param data The vector to which the value should be added. */ public void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data) { String name = getName(); double w = getWeight(originalForm1, originalForm2, weight); for (int i = 0; i < probes(); i++) { Iterable<Integer> jValues = secondEncoder.hashesForProbe(originalForm2, data.size(), name, i % secondEncoder.getProbes()); for (Integer k : firstEncoder.hashesForProbe(originalForm1, data.size(), name, i % firstEncoder.getProbes())) { for (Integer j : jValues) { int n = (k + j) % data.size(); if (isTraceEnabled()) { trace(String.format("%s:%s", new String(originalForm1, Charsets.UTF_8), new String(originalForm2, Charsets.UTF_8)), n); } data.set(n, data.get(n) + w); } } } }
/** * Adds a value to a vector. * * @param originalForm1 The original form of the first value as a byte array. * @param originalForm2 The original form of the second value as a byte array. * @param weight How much to weight this interaction * @param data The vector to which the value should be added. */ public void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data) { String name = getName(); double w = getWeight(originalForm1, originalForm2, weight); for (int i = 0; i < probes(); i++) { Iterable<Integer> jValues = secondEncoder.hashesForProbe(originalForm2, data.size(), name, i % secondEncoder.getProbes()); for (Integer k : firstEncoder.hashesForProbe(originalForm1, data.size(), name, i % firstEncoder.getProbes())) { for (Integer j : jValues) { int n = (k + j) % data.size(); if (isTraceEnabled()) { trace(String.format("%s:%s", new String(originalForm1, Charsets.UTF_8), new String(originalForm2, Charsets.UTF_8)), n); } data.set(n, data.get(n) + w); } } } }