[Mmil-commits] r74 - trunk/src/fr/loria/talaris/mmil

alexandredenis at users.gforge.inria.fr alexandredenis at users.gforge.inria.fr
Mar 14 Déc 16:55:13 CET 2010


Author: alexandredenis
Date: 2010-12-14 16:55:13 +0100 (Tue, 14 Dec 2010)
New Revision: 74

Modified:
   trunk/src/fr/loria/talaris/mmil/DefaultMMILComponent.java
Log:
Updated setMainEvent to prefer events with a dialogueAct feature over other candidates

Modified: trunk/src/fr/loria/talaris/mmil/DefaultMMILComponent.java
===================================================================
--- trunk/src/fr/loria/talaris/mmil/DefaultMMILComponent.java	2010-07-23 10:22:12 UTC (rev 73)
+++ trunk/src/fr/loria/talaris/mmil/DefaultMMILComponent.java	2010-12-14 15:55:13 UTC (rev 74)
@@ -404,18 +404,24 @@
 			throw new MMILException("Unable to set main event: too many propContent relations\n" + this);
 		else if (propContents.isEmpty())
 		{
-			// in case there is no propContent, take the first found event
-			boolean found = false;
-			for(MMILEntity entity : getEntities())
-				if (entity instanceof MMILEvent)
-				{
-					setMainEvent((MMILEvent) entity);
-					found = true;
-					break;
-				}
-			if (!found)
+			// in case there is no propContent, take the first found event with a dialogue act
+			// if there is none, take first found event, if there is none throw exception
+			Collection<MMILEvent> events = getEvents();
+			if (events.isEmpty())
 				throw new MMILException("Unable to set main event: no propContent relation and no event at all\n"
-						+ this);
+										+ this);
+			else
+			{
+				for(MMILEvent event : events)
+					if (event.hasFeature("dialogueAct"))
+					{
+						setMainEvent(event);
+						return;
+					}
+				
+				// no dialogue act found, take first event.
+				setMainEvent(events.iterator().next());
+			}
 		}
 		else
 		{




More information about the Mmil-commits mailing list