Skip to main content

DocuMine Documentation

Binding first entity found of a type to component

You can bind the first entity found of a certain type to a component:

rule "StudyTitle.0.0: First Title found"
    when
        $titleCandidates: List() from collect (Entity(type == "title"))
    then
        componentCreationService
          .firstOrElse(
            "StudyTitle.0.0",
            "Study_Title",
            $titleCandidates,
            ""
          );
    end

The following table provides a detailed breakdown of the rule syntax:

Syntax

Explanation

rule "Sponsor.0.0"

Name of the rule

Each rule must have a unique name. For further information, please see Rule naming.

$titleCandidates: List() from collect (Entity(type == "title"))

Finds all entities of type “title”, saves them in a list, and binds that list to the $titleCandidates variable.

.firstOrElse("StudyTitle.0.0", "Study_Title", $titleCandidates, "");

The method takes four parameters: the first is the rule identifier, which must be equal to the rule name to later identify the component; in this case, it is 'StudyTitle.0.0.' The second parameter specifies the name to be assigned to the component, here 'Study_Title.' The third parameter is a list of Entity Objects, from which the first (ordered by appearance in the document from left to right) will be used to create a component. The fourth parameter specifies the fallback value, which in this case is an empty string (''). This value will be used if the list is empty.

Notice

For further information about the methods listed in the table, please refer to the relevant sections in the Javadoc documentation:

https://docs.documine.ai/javadoc/index.html