[ 
https://issues.apache.org/jira/browse/OPENNLP-1151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16216027#comment-16216027
 ] 

ASF GitHub Bot commented on OPENNLP-1151:
-----------------------------------------

kottmann commented on a change in pull request #282: OPENNLP-1151: All Sample 
objects should implement Serializable for easy integration into other tools
URL: https://github.com/apache/opennlp/pull/282#discussion_r146419068
 
 

 ##########
 File path: 
opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTest.java
 ##########
 @@ -61,6 +71,36 @@ private static NameSample createSimpleNameSample(boolean 
useTypes) {
     return nameSample;
   }
 
+  @Test
+  public void testNameSampleSerDe() throws IOException {
+    NameSample nameSample = createGoldSample();
+    String fileName = "file.ser";
+
+    try (FileOutputStream fileOutputStream =
+             new FileOutputStream(tempDirectory.newFile(fileName))) {
+      ObjectOutputStream objectOutputStream = new 
ObjectOutputStream(fileOutputStream);
+      objectOutputStream.writeObject(nameSample);
+      objectOutputStream.close();
+    }
+
+    NameSample deSerializedNameSample = null;
+
+    try (FileInputStream fileInputStream =
+             new FileInputStream(new File(tempDirectory.getRoot(), fileName))) 
{
+      ObjectInputStream objectInputStream = new 
ObjectInputStream(fileInputStream);
+      deSerializedNameSample = (NameSample) objectInputStream.readObject();
+    } catch (ClassNotFoundException cfe) {
+      // do nothing
+    }
+
+    Assert.assertNotNull(deSerializedNameSample);
 
 Review comment:
   Should be enough to call NameSample.equals instead of comparing it here

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> All Sample objects should implement Serializable for easy interation into 
> other tools
> -------------------------------------------------------------------------------------
>
>                 Key: OPENNLP-1151
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1151
>             Project: OpenNLP
>          Issue Type: Bug
>            Reporter: Joern Kottmann
>            Assignee: Suneel Marthi
>            Priority: Minor
>             Fix For: 1.8.3
>
>
> State of the Art frameworks like Apache Flink require that objects are 
> serializable to use them in the pipeline. To use it to prepare training date 
> for OpenNLP the Sample objects should all implement Serializable.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to