@Override public int hashCode() { return Objects.hash(getCategory(), Arrays.hashCode(getText())); }
/** * Evaluates the given reference {@link DocumentSample} object. * * This is done by categorizing the document from the provided * {@link DocumentSample}. The detected category is then used * to calculate and update the score. * * @param sample the reference {@link TokenSample}. */ public DocumentSample processSample(DocumentSample sample) { String[] document = sample.getText(); double[] probs = categorizer.categorize(document); String cat = categorizer.getBestCategory(probs); if (sample.getCategory().equals(cat)) { accuracy.add(1); } else { accuracy.add(0); } return new DocumentSample(cat, sample.getText()); }
public Event next() { isVirgin = false; return new Event(sample.getCategory(), mContextGenerator.getContext(sample.getText(), sample.getExtraInformation())); }
private void statsAdd(DocumentSample reference, DocumentSample prediction) { getStats().add(reference.getText(), reference.getCategory(), prediction.getCategory()); }
@Test public void testDocumentSampleSerDe() throws IOException { DocumentSample documentSample = createGoldSample(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(byteArrayOutputStream); out.writeObject(documentSample); out.flush(); byte[] bytes = byteArrayOutputStream.toByteArray(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); ObjectInput objectInput = new ObjectInputStream(byteArrayInputStream); DocumentSample deSerializedDocumentSample = null; try { deSerializedDocumentSample = (DocumentSample) objectInput.readObject(); } catch (ClassNotFoundException e) { // do nothing } Assert.assertNotNull(deSerializedDocumentSample); Assert.assertEquals(documentSample.getCategory(), deSerializedDocumentSample.getCategory()); Assert.assertArrayEquals(documentSample.getText(), deSerializedDocumentSample.getText()); }
@Override public int hashCode() { return Objects.hash(getCategory(), Arrays.hashCode(getText())); }
@Override public int hashCode() { return Objects.hash(getCategory(), Arrays.hashCode(getText())); }
/** * Evaluates the given reference {@link DocumentSample} object. * * This is done by categorizing the document from the provided * {@link DocumentSample}. The detected category is then used * to calculate and update the score. * * @param sample the reference {@link TokenSample}. */ public DocumentSample processSample(DocumentSample sample) { String[] document = sample.getText(); double[] probs = categorizer.categorize(document); String cat = categorizer.getBestCategory(probs); if (sample.getCategory().equals(cat)) { accuracy.add(1); } else { accuracy.add(0); } return new DocumentSample(cat, sample.getText()); }
/** * Evaluates the given reference {@link DocumentSample} object. * * This is done by categorizing the document from the provided * {@link DocumentSample}. The detected category is then used * to calculate and update the score. * * @param sample the reference {@link TokenSample}. */ public DocumentSample processSample(DocumentSample sample) { String[] document = sample.getText(); double[] probs = categorizer.categorize(document); String cat = categorizer.getBestCategory(probs); if (sample.getCategory().equals(cat)) { accuracy.add(1); } else { accuracy.add(0); } return new DocumentSample(cat, sample.getText()); }
public Event next() { isVirgin = false; return new Event(sample.getCategory(), mContextGenerator.getContext(sample.getText(), sample.getExtraInformation())); }
public Event next() { isVirgin = false; return new Event(sample.getCategory(), mContextGenerator.getContext(sample.getText(), sample.getExtraInformation())); }
private void statsAdd(DocumentSample reference, DocumentSample prediction) { getStats().add(reference.getText(), reference.getCategory(), prediction.getCategory()); }
private void statsAdd(DocumentSample reference, DocumentSample prediction) { getStats().add(reference.getText(), reference.getCategory(), prediction.getCategory()); }