ilog.rules.vocabulary.model.helper

Class IlrVocabularyHelper

  • java.lang.Object
    • ilog.rules.vocabulary.model.helper.IlrVocabularyHelper


  • public final class IlrVocabularyHelper
    extends java.lang.Object
    This class provides various facilities for manipulating a vocabulary and its artifacts.
    • Constructor Detail

      • IlrVocabularyHelper

        public IlrVocabularyHelper()
    • Method Detail

      • cleanDeleteConcept

        public static void cleanDeleteConcept(IlrConcept concept)
        Removes a concept and all related concepts, fact types, sentences and concept instances.
        Parameters:
        concept - The concept to remove.
      • allSentencesList

        public static java.util.List allSentencesList(IlrVocabulary vocabulary)
        Returns the list of all sentences defined in the specified vocabulary.
        Parameters:
        vocabulary - The vocabulary.
        Returns:
        A list of all sentences.
      • getAllParents

        public static java.util.Collection getAllParents(IlrConcept concept,
                                         IlrVocabulary vocabulary)
        Gets the collection of all direct and indirect parents of the specified concept, for the given vocabulary.
        Parameters:
        concept - The concept.
        vocabulary - The vocabulary.
        Returns:
        The collection of all parents of the concept.
      • isSubConceptOf

        public static boolean isSubConceptOf(IlrConcept subConcept,
                             IlrConcept superConcept,
                             IlrVocabulary vocabulary)
        Returns true if subConcept equals superConcept or if subConcept is a sub concept of superConcept.
        Parameters:
        subConcept - The concept to examine.
        superConcept - The concept that is tested to be the parent of subConcept.
        Returns:
        true if subConcept equals superConcept or if subConcept is a subconcept of superConcept.
      • findElement

        public static IlrVocabularyElement findElement(java.lang.String identifier,
                                       IlrVocabulary vocabulary)
        Finds a vocabulary element by its identifier from the given vocabulary.
        Parameters:
        identifier - The identifier of the vocabulary element to find.
        vocabulary - The vocabulary to look into.
        Returns:
        The vocabulary element found or null.
      • findArtifact

        public static IlrBusinessArtifact findArtifact(java.lang.String name,
                                       IlrVocabulary vocabulary)
        Finds a business artifact by its name from the given vocabulary.
        Parameters:
        name - The name of the business artifact to find.
        vocabulary - The vocabulary to look into.
        Returns:
        The business artifact found or null.
      • findSentence

        public static IlrSentence findSentence(java.lang.String fullName,
                               IlrVocabulary vocabulary)
        Finds a sentence by its full name from the specified vocabulary. The full name expected is defined as follows: <fact type identifier> + "/" + <sentence identifier>
        Parameters:
        fullName - The sentence full name.
        vocabulary - The vocabulary.
        Returns:
        Either the sentence found, or null.
      • findSentence

        public static IlrSentence findSentence(java.lang.String identifier,
                               IlrFactType factType)
        Finds a sentence from its identifier, from the specified fact type.
        Parameters:
        identifier - The sentence identifier.
        factType - The fact type.
        Returns:
        Either the sentence found, or null.
      • findSentencesForCategory

        public static java.util.List findSentencesForCategory(IlrSentenceCategory category,
                                              IlrFactType factType)
        Gets the list of sentences of the specified sentence category, from the given fact type.
        Parameters:
        category - The category.
        factType - The fact type.
        Returns:
        The list of sentences using this category.
      • findConceptByLabel

        public static IlrConcept findConceptByLabel(java.lang.String label,
                                    IlrVocabulary vocabulary)
        Finds a concept by its label.
        Parameters:
        label - The label.
        vocabulary - The vocabulary.
        Returns:
        Either the concept found, or null.
      • findConceptInstanceByLabel

        public static IlrConceptInstance findConceptInstanceByLabel(java.lang.String label,
                                                    IlrVocabulary vocabulary)
        Finds a concept instance by its label.
        Parameters:
        label - The label.
        vocabulary - The vocabulary.
        Returns:
        Either the concept instance found, or null.
      • getSyntacticRoleForRole

        public static IlrSyntacticRole getSyntacticRoleForRole(IlrRole role,
                                               IlrSentence sentence)
        Gets the syntactic role corresponding to role from sentence.
        Parameters:
        role - The role.
        sentence - The sentence.
        Returns:
        Either the syntactic role found, or null.
      • getSubjectSyntacticRole

        public static IlrSyntacticRole getSubjectSyntacticRole(IlrSentence sentence)
        Gets the subject syntactic role from the specified sentence.
        Parameters:
        sentence - The sentence.
        Returns:
        The subject syntactic role, or null if the sentence has no subject.
      • getSubjectRole

        public static IlrRole getSubjectRole(IlrSentence sentence)
        Returns the subject role of the specified sentence.
        Parameters:
        sentence - The sentence.
        Returns:
        Either the role found, or null.
      • getSentenceCardinality

        public static IlrCardinality getSentenceCardinality(IlrSentence sentence)
        Returns the cardinality of the subject role. This can be considered as the cardinality of the whole sentence. A sentence with no subject returns a single cardinality.
        Parameters:
        sentence - The sentence.
        Returns:
        The cardinality of the sentence.
      • getOwnerRole

        public static IlrRole getOwnerRole(IlrFactType factType)
        Returns the owner role of a fact type.
        Parameters:
        factType - The fact type.
        Returns:
        The owner role of this fact type. If the fact type has no owner role, null is returned.
        See Also:
        isOwner(IlrRole role)
      • isOwner

        public static boolean isOwner(IlrRole role)
        Tests if the specified role is marked as owner.
        Parameters:
        role - The role
        Returns:
        If role is marked as owner, true is returned.
      • getOwnedRole

        public static IlrRole getOwnedRole(IlrFactType factType)
        Returns the owned role of a fact type. It returns null if the fact type has no owned role.
        Parameters:
        factType - The fact type.
        Returns:
        The owned role of this fact type.
        See Also:
        isOwner(IlrRole role)
      • isOwned

        public static boolean isOwned(IlrRole role)
        Tests if the specified role is marked as owned.
        Parameters:
        role - The role
        Returns:
        true if the role is marked as owned.
      • getNonHolderRoles

        public static IlrRole[] getNonHolderRoles(IlrFactType factType)
        Returns all non holder roles of the specified fact type.
        Parameters:
        factType - The fact type.
        Returns:
        The array of roles that are not holders.
      • getThisSyntacticRole

        public static IlrSyntacticRole getThisSyntacticRole(IlrSentence sentence)
        Returns the syntactic role of the sentence, which corresponds to the holder role.
        Parameters:
        sentence - The sentence.
        Returns:
        The syntactic role corresponding to the holder role.
      • getObjectRoles

        public static java.util.List getObjectRoles(IlrSentence sentence)
        Returns the list of all object roles of the specified sentence.
        Parameters:
        sentence - The sentence.
        Returns:
        The list of roles that have the category IlrSyntacticRoleCategory.OBJECT_LITERAL. Each element of the list is an instance of IlrRole.
      • getSystemVocabulary

        public static IlrVocabulary getSystemVocabulary(IlrVocabulary vocabulary)
        Retrieves the Boot vocabulary stored in the vocabulary set, if the vocabulary is a vocabulary set.
        Parameters:
        vocabulary - The vocabulary.
        Returns:
        The system vocabulary, or null if the vocabulary is not a vocabulary set.
      • isSystem

        public static boolean isSystem(IlrVocabulary voc)
        This method tests whether the given vocabulary is identified as a "boot vocabulary". Elements of boot vocabulary are placed in a "System" category in vocabulary view for instance. A vocabulary is considered as "boot" if it has the property "BootVocabulary" set to true.
        Parameters:
        voc -
        Returns:
        true if the given vocabulary is identified as "boot"
      • isSystem

        public static boolean isSystem(IlrVocabularyElement elt)
        Tests if the given vocabulary element is part of the "boot vocabulary".
        Parameters:
        elt - A vocabulary element.
        Returns:
        If the given vocabulary element is part of a vocabulary which has been identified as "boot", true is returned.
        See Also:
        isSystem(IlrVocabulary).
      • copyVocabulary

        public static IlrVocabulary copyVocabulary(IlrVocabulary vocabulary)
        Creates a deep copy of the specified vocabulary.
        Parameters:
        vocabulary - The vocabulary to be copied.
        Returns:
        The copied vocabulary.
      • copyVocabularyContents

        public static void copyVocabularyContents(IlrVocabulary source,
                                  IlrVocabulary target)
        Clones a source vocabulary and puts the result into a target vocabulary.
        Parameters:
        source - The source vocabulary.
        target - The target vocabulary.
      • isUsedAsSubject

        public static boolean isUsedAsSubject(IlrRole r)
        Checks if the role is used as a subject in one sentence of the fact type.
        Parameters:
        r -
        Returns:
        True if r is the subject role.
      • getHolderRoleIndex

        public static int getHolderRoleIndex(IlrSentence sentence)
        Returns the index of the holder role in the given sentence. It is also the position of the role node in an AST. Note that if the holder role is not present in the sentence template, this method returns -1.
        Parameters:
        sentence -
        Returns:
        The index of the holder role in the sentence.
      • getOwnerSyntacticRole

        public static IlrSyntacticRole getOwnerSyntacticRole(IlrSentence sentence)
        Gets the owner syntactic role for the specified sentence.
        Parameters:
        sentence - The sentence.
        Returns:
        The owner syntactic role.
      • getOwnerSyntacticRole

        public static IlrSyntacticRole getOwnerSyntacticRole(java.util.List syntacticRoles)
        Gets the owner syntactic role from the specified list of getOwnerSyntacticRole.
        Parameters:
        syntacticRoles - The list of syntactic roles.
        Returns:
        The owner syntactic roles.
      • getOwnedSyntacticRole

        public static IlrSyntacticRole getOwnedSyntacticRole(IlrSentence sentence)
        Gets the owned syntactic role for the specified sentence.
        Parameters:
        sentence - The sentence.
        Returns:
        The owned syntactic role.
      • getOwnedSyntacticRole

        public static IlrSyntacticRole getOwnedSyntacticRole(java.util.List syntacticRoles)
        Gets the owned syntactic role from the specified list of getOwnerSyntacticRole.
        Parameters:
        syntacticRoles - The list of syntactic roles.
        Returns:
        The owned syntactic roles.
      • getArgumentsSyntacticRoles

        public static java.util.List getArgumentsSyntacticRoles(java.util.List syntacticRoles)
        Returns the sublist of syntactic roles that are not owned nor owner.
        Parameters:
        syntacticRoles - The list of syntactic roles.
        Returns:
        The list of roles that are not owned or owner.
      • getRepresentedSyntacticRoles

        public static java.util.List getRepresentedSyntacticRoles(IlrSentence sentence)
        This helper method returns the syntactic roles that are represented in the sentence template.
        Parameters:
        sentence -
        Returns:
        a list of syntactic roles as they appear in the sentence template and an empty list if none are represented in the template. This method returns null if an error occurs while processing the sentence template.
      • isDeprecated

        public static boolean isDeprecated(IlrVocabularyElement vocElement)
        Checks if the vocabulary element has the deprecated property.
        Parameters:
        vocElement - The vocabulary element.
        Returns:
        true if the vocElement is marked as deprecated.
      • getRoleIdentifier

        public static java.lang.String getRoleIdentifier(IlrRole role)
        Returns the string identifier of a fact type role.
        Parameters:
        role - The role.
        Returns:
        The role identifier.
      • getRole

        public static IlrRole getRole(java.lang.String roleIdentifier,
                      IlrVocabulary vocabulary)
        Returns a role from its identifier.
        Parameters:
        roleIdentifier - The role identifier.
        vocabulary - The vocabulary
        Returns:
        Either the role found, or null.
      • removeAllSentences

        public static void removeAllSentences(IlrFactType factType)
        Removes all sentences from the specified fact type.
        Parameters:
        factType - The fact type.
      • getAllProperties

        public static java.util.Map getAllProperties(IlrBaseElement element,
                                     IlrVocabulary vocabulary)
        Returns all properties defined on the element as a map.
        Parameters:
        element - The base element.
        vocabulary - The vocabulary.
        Returns:
        The map of all properties defined on element.
      • getPrototypeSentenceRoleLabel

        public static IlrVerbalizable getPrototypeSentenceRoleLabel(IlrSyntacticRole role)
        Returns the label of the role in a way to be verbalized. A RuntimeException is thrown if there is no specified label on the role.
        Returns:
        the label of the role in a way to be verbalized

© Copyright IBM Corp. 1987, 2017