Carrot2

Simple controller throws binding exception error unexpectedly.

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 3.3.0
  • Fix Version/s: 3.4.0
  • Component/s: Framework Core
  • Labels:
    None

Description

Execute ClusteringDataFromDocumentSources. With the simple controller it throws:

Exception in thread "main" org.carrot2.util.attribute.AttributeBindingException: No value for required attribute: documents (org.carrot2.clustering.lingo.LingoClusteringAlgorithm#documents)
	at org.carrot2.util.attribute.AttributeBinder$AttributeBinderActionBind.performAction(AttributeBinder.java:543)
	at org.carrot2.util.attribute.AttributeBinder.bind(AttributeBinder.java:309)
	at org.carrot2.util.attribute.AttributeBinder.bind(AttributeBinder.java:214)
	at org.carrot2.util.attribute.AttributeBinder.bind(AttributeBinder.java:159)
	at org.carrot2.util.attribute.AttributeBinder.bind(AttributeBinder.java:137)
	at org.carrot2.util.attribute.AttributeBinder.bind(AttributeBinder.java:124)
	at org.carrot2.core.SimpleProcessingComponentManager.prepare(SimpleProcessingComponentManager.java:59)
	at org.carrot2.core.Controller.process(Controller.java:273)
	at org.carrot2.core.Controller.process(Controller.java:180)
	at org.carrot2.examples.clustering.ClusteringDataFromDocumentSources.main(ClusteringDataFromDocumentSources.java:62)

This is wrong because documents are set as a result of Bing's invocation. Tracing the controller logic it makes me wonder what this piece of code does:

Controller.java:

                // Create a component for processing. Depending on the manager, a new
                // component may be instantiated, a pooled one may be returned or we may
                // get some wrapper that performs some extra actions.
                components[i] = componentManager.prepare(
                    configurations[i].componentClass, configurations[i].componentId,
                    inputAttributes, resultAttributes);

but then, this in SimpleProcessingComponentManager is:

{pre}
ControllerUtils.init(component, inputAttributes, outputAttributes, true,
context);

// To support a scenario where processing input attributes are provided
// at init-time, we need to bind them here as well.
AttributeBinder.bind(component, inputAttributes, Input.class,
Processing.class);{pre}

inputAttributes does not contain documents at all and resultAttributes is not used to initialize the component; hence, you get an exception during bind() because documents are required at @Processing step.

Activity

Hide
Stanisław Osiński added a comment -

Fixed in trunk.

Show
Stanisław Osiński added a comment - Fixed in trunk.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: