001package de.monochromata.anaphors.ast.reference.strategy.concept;
002
003import de.monochromata.anaphors.ast.feature.FeatureContainer;
004import de.monochromata.anaphors.ast.reference.Referent;
005import de.monochromata.anaphors.ast.reference.strategy.ReferentializationStrategy;
006import de.monochromata.anaphors.ast.reference.strategy.feature.FeatureReferentializationStrategy;
007
008/**
009 * A referentialization strategy that interprets identifiers from right to left
010 * and refers to the conceptual type(TODO: ?), assuming that the conceptual type
011 * is not just another feature (TODO: find literature reference).
012 *
013 * <p>
014 * A number of cases can be distinguished:
015 * <ol>
016 * <li>Neither the entire definite expression nor a suffix of it refer to the
017 * conceptual type of the potential referent. In this case
018 * {@link #canReferToUsingConceptualType(Object, Referent, Object)} returns
019 * false and
020 * {@link #getFeaturesRemainingInIdentifierIfItCanReferUsingConceptualType(Object, Referent, Object)}
021 * returns {@code null}.</li>
022 * <li>The entire definite expression refers to the conceptual type of the
023 * potential referent. In this case
024 * {@link #canReferToUsingConceptualType(Object, Referent, Object)} returns true
025 * and
026 * {@link #getFeaturesRemainingInIdentifierIfItCanReferUsingConceptualType(Object, Referent, Object)}
027 * returns an empty {@link FeatureContainer}.</li>
028 * <li>A suffix of the definite expression refers to the conceptual type of the
029 * potential referent. In this case
030 * {@link #canReferToUsingConceptualType(Object, Referent, Object)} returns true
031 * and
032 * {@link #getFeaturesRemainingInIdentifierIfItCanReferUsingConceptualType(Object, Referent, Object)}
033 * returns a non-empty {@link FeatureContainer}.</li>
034 * </ol>
035 *
036 * @param <E>  The expression type
037 * @param <TB> The type binding type
038 * @param <S>  The scope type (optional)
039 * @param <I>  The type used to represent identifiers
040 * @param <QI> The type used to represent qualified identifiers
041 *
042 * @see FeatureContainer#isEmpty()
043 */
044public interface ConceptReferentializationStrategy<E, TB, S, I, QI>
045        extends ReferentializationStrategy<E, TB, S, I, QI> {
046
047    /**
048     * Checks whether the given definite expression can, using this
049     * referentialization strategy, refer to the given potential referent in the
050     * given scope. Unlike {@link #canReferTo(Object, Referent, Object)}, this
051     * method requires only conceptual-type information in a suffix of the definite
052     * expression to be matched by the information of the given potential referent
053     * for the method to return true. Matching is performed in a way that is
054     * specific to the referentialization strategy.
055     *
056     * @param idFromDefiniteExpression the ID from the definite expression that
057     *                                 shall refer to the given potential referent
058     * @param potentialReferent        the potential referent to refer to
059     * @param scope                    the scope in which the definite expression
060     *                                 occurs
061     * @return {@code true} if the conceptual-type information provided by a suffix
062     *         of the definite expression matches the information provided by the
063     *         potential referent, where matching depends on the implementation of
064     *         this method, {@code false} otherwise.
065     */
066    public boolean canReferToUsingConceptualType(I idFromDefiniteExpression, Referent<TB, S, I, QI> potentialReferent,
067            S scope);
068
069    /**
070     * If {@link #canReferToUsingConceptualType(Object, Referent, Object)} returns
071     * {@code true} for the given arguments, there is a suffix in the given definite
072     * expression that represents a conceptual type and can be used to refer to the
073     * given potential referent. In this case, this method returns a
074     * {@link FeatureContainer} with all features that can be extracted from the
075     * remainder of the given definite expression after the suffix has been removed.
076     * If the remainder is empty, the {@link FeatureContainer} is empty, too.
077     *
078     * @param idFromDefiniteExpression The ID from the definite expression whose
079     *                                 features are to be extracted.
080     * @param potentialReferent        The potential referent of the definite
081     *                                 expression.
082     * @param scope                    An optional scope object specific to the AST
083     *                                 implementation.
084     * @return {@code null}, if
085     *         {@link #canReferToUsingConceptualType(Object, Referent, Object)}
086     *         returns false, a (possibly) empty {@link FeatureContainer} if
087     *         {@link #canReferToUsingConceptualType(Object, Referent, Object)}
088     *         returns true.
089     * @see FeatureReferentializationStrategy
090     */
091    public FeatureContainer<QI> getFeaturesRemainingInIdentifierIfItCanReferUsingConceptualType(
092            I idFromDefiniteExpression, Referent<TB, S, I, QI> potentialReferent, S scope);
093
094}