[Mmil-commits] r25 - trunk/src/fr/loria/led/mmil

alexandredenis at users.gforge.inria.fr alexandredenis at users.gforge.inria.fr
Mer 4 Oct 09:52:58 CEST 2006


Author: alexandredenis
Date: 2006-10-04 07:52:57 +0000 (Wed, 04 Oct 2006)
New Revision: 25

Modified:
   trunk/src/fr/loria/led/mmil/MMILEntity.java
Log:


Modified: trunk/src/fr/loria/led/mmil/MMILEntity.java
===================================================================
--- trunk/src/fr/loria/led/mmil/MMILEntity.java	2006-10-03 11:25:37 UTC (rev 24)
+++ trunk/src/fr/loria/led/mmil/MMILEntity.java	2006-10-04 07:52:57 UTC (rev 25)
@@ -247,13 +247,18 @@
 		Collections.sort(features);	
 	}
 
+    
+    public MMILEntity unify(MMILEntity entity)
+    {
+        return unify(entity, new ArrayList<List<String>>());
+    }
 
     /**
         Unify this entity to the given entity.
         Two entities 
         @return null if no unification was possible.
     */
-    public MMILEntity unify(MMILEntity entity)
+    public MMILEntity unify(MMILEntity entity, List<List<String>> synonyms)
     {
         if (!getMMILType().equals(entity.getMMILType()))
             return null;
@@ -261,7 +266,7 @@
         MMILEntity ret = entity instanceof MMILParticipant ? new MMILParticipant() : new MMILEvent();
         for(MMILFeature feat : features)
         {
-            List<String> values = entity.getValuesOf(feat.getName());
+            List<String> values = synonymize(entity.getValuesOf(feat.getName()), synonyms);
             if (values.isEmpty() || containsIgnoreCase(values, feat.getValue()))
             {
                 if (!ret.hasFeature(feat.getNamespace(), feat.getName(), feat.getValue()))
@@ -271,7 +276,7 @@
         }
         for(MMILFeature feat : entity.getFeatures())
         {
-            List<String> values = getValuesOf(feat.getName());
+            List<String> values = synonymize(getValuesOf(feat.getName(), synonyms));
             if (values.isEmpty() || containsIgnoreCase(values, feat.getValue()))
             {
                 if (!ret.hasFeature(feat.getNamespace(), feat.getName(), feat.getValue()))
@@ -283,6 +288,22 @@
     }
 
     /**
+        Completes the given list of strings with synonyms.
+        It searches for synonyms for each element of the list and adds them to the list.
+    */
+    private List<String> synonymize(List<String> list, List<List<String>> synonyms)
+    {
+        List<String> ret = new ArrayList<String>();
+        ret.addAll(list);
+        for(String s : list)
+            for(List<String> synList : synonyms)
+                if (containsIgnoreCase(synList, s))
+                    ret.addAll(synList);
+        return ret;
+    }
+
+
+    /**
         Tests if a list of strings contains a given string without case.
     */
     private boolean containsIgnoreCase(List<String> list, String str)






Plus d'informations sur la liste de diffusion Mmil-commits