changeset 77:a59984fd3c3f

add normalized own-values to xml dump.
author casties
date Thu, 02 Mar 2017 20:23:43 +0100
parents f04bd29d284d
children b32b176a8aad
files src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java src/main/java/org/mpi/openmind/repository/utils/XMLUtil.java
diffstat 2 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java	Fri Feb 24 20:22:23 2017 +0100
+++ b/src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java	Thu Mar 02 20:23:43 2017 +0100
@@ -33,6 +33,9 @@
     private static Logger logger = Logger.getLogger(OM4StreamWriter.class);
 
     private static int itemsPerPage = 500;
+    
+    /** Include normalized own-values. */
+    public static boolean includeNorm = true;
 
     /**
      * Return the object's string representation or "null" if its null.
@@ -92,12 +95,12 @@
 
             if (type.equals(Node.TYPE_ABOX)) {
                 writer.writeStartElement(XMLUtil.OPENMIND_DATA);
-                writer.writeAttribute("version", "4.3");
+                writer.writeAttribute("version", "4.4");
                 // get number of content Entities
                 entitiesCount = ps.getEntityCount(null).intValue();
             } else {
                 writer.writeStartElement(XMLUtil.META_DATA);
-                writer.writeAttribute("version", "4.3");
+                writer.writeAttribute("version", "4.4");
                 // get number of definition Entities
                 entitiesCount = ps.getEntityCount(Node.TYPE_TBOX).intValue();
             }
@@ -273,8 +276,16 @@
         /*
          * write own value
          */
-        if (StringUtils.isNotEmpty(entity.getOwnValue())) {
-            writer.writeCharacters(entity.getOwnValue());
+        String ov = entity.getOwnValue();
+		if (StringUtils.isNotEmpty(ov)) {
+            writer.writeCharacters(ov);
+            String nov = entity.getNormalizedOwnValue();
+			if (includeNorm && StringUtils.isNotEmpty(nov) && !ov.equals(nov)) {
+                // write normalized value
+            	writer.writeStartElement(XMLUtil.NORMALIZED);
+            	writer.writeCharacters(nov);
+            	writer.writeEndElement();
+            }
         }
 
         writer.writeEndElement();
@@ -302,8 +313,16 @@
         /*
          * write value as content
          */
-        if (StringUtils.isNotEmpty(att.getValue())) {
-            writer.writeCharacters(att.getValue());
+        String ov = att.getValue();
+		if (StringUtils.isNotEmpty(ov)) {
+            writer.writeCharacters(ov);
+            String nov = att.getNormalizedOwnValue();
+			if (includeNorm && StringUtils.isNotEmpty(nov) && !ov.equals(nov)) {
+                // write normalized value
+            	writer.writeStartElement(XMLUtil.NORMALIZED);
+            	writer.writeCharacters(nov);
+            	writer.writeEndElement();
+            }
         }
         
         writer.writeEndElement();
--- a/src/main/java/org/mpi/openmind/repository/utils/XMLUtil.java	Fri Feb 24 20:22:23 2017 +0100
+++ b/src/main/java/org/mpi/openmind/repository/utils/XMLUtil.java	Thu Mar 02 20:23:43 2017 +0100
@@ -43,7 +43,6 @@
     
     public static String PRINT_RULES = "print-rules";
     public static String PRINT_RULE = "print-rule";
-
     
     public static String OPENMIND_DATA = "openmind-data";
     public static String ENTITIES = "entities";
@@ -68,6 +67,7 @@
     public static String CONCEPT = "concept";
     public static String ASSERTIONS = "assertions";
     public static String ASSERTION = "assertion";
+    public static String NORMALIZED = "norm";
     
     //names used by the previous version of ismi.
     public static String META_DATA = "openmind-meta";