001package de.monochromata.anaphors.ast.spi; 002 003import java.util.List; 004import java.util.function.Predicate; 005 006import de.monochromata.anaphors.ast.feature.FeatureContainer; 007import de.monochromata.anaphors.ast.reference.Referent; 008import de.monochromata.anaphors.perspectivation.Perspectivation; 009 010/** 011 * The service provider interface used by the 012 * <code>de.monochromata.anaphors</code> package to perform anaphora resolution 013 * on a given AST implementation. 014 * 015 * @param <N> The node type in the AST 016 * @param <E> The expression type 017 * @param <TB> The type binding type 018 * @param <S> The scope type (optional) 019 * @param <I> The type used to represent identifiers 020 * @param <QI> The type used to represent qualified identifiers 021 * @param <EV> The type of the event contained in the condition that is 022 * evaluated to check when the perspectivations shall be applied. 023 * @param <PP> The type used for positions that carry perspectivations 024 */ 025public interface AnaphorsSpi<N, E, TB, S, I, QI, EV, PP> { 026 027 public boolean isSimpleName(E definiteExpression); 028 029 public I getIdentifierOfSimpleName(E simpleName); 030 031 public boolean nameOfReferentEqualsIdentifier(Referent<TB, S, I, QI> referent, I id, boolean caseSensitive); 032 033 /** 034 * Returns true, if the name of the referent matches a suffix of the identifier. 035 * 036 * @param referent the referent whose name to match 037 * @param id the id to match 038 * @param caseSensitive whether case should be considered during matching 039 * @return {@code true}, if the name of the referent matches a suffix of the 040 * identifier, {@code false} otherwise (including when the referent has 041 * no name). 042 * @see Referent#hasName() 043 */ 044 public boolean nameOfReferentMatchesConceptualTypeOfIdentifier(Referent<TB, S, I, QI> referent, I id, 045 boolean caseSensitive); 046 047 public FeatureContainer<QI> getFeaturesRemainingInIdentifierBesidesConceptualTypeOfReferentName(I id, 048 Referent<TB, S, I, QI> referent, boolean caseSensitive); 049 050 /** 051 * Test whether the given identifier matches the simple name of the given type 052 * binding. 053 * 054 * TODO: Add the possibility to match prefix/suffix 055 * 056 * @param id The identifier to match. 057 * @param type The typing binding whose simple name is to be matched. 058 * @param caseSensitive True, if case is to be considered, false, if it is to be 059 * ignored. TODO: What about the initial character? 060 * @return True, if the identifier matches the simple name of the type binding, 061 * false otherwise. 062 */ 063 public boolean nameOfIdentifierEqualsSimpleNameOfTypeBinding(I id, TB type, boolean caseSensitive); 064 065 public boolean conceptualTypeInIdentifierEqualsSimpleNameOfType(I id, TB type, boolean caseSensitive); 066 067 public FeatureContainer<QI> getFeaturesRemainingInIdentifierBesidesConceptualTypeOfReferentType(I id, 068 TB referentType, boolean caseSensitive); 069 070 public boolean nameOfIdentifierEqualsFauxHyponymOfSimpleNameOfTypeBinding(I id, TB type, boolean caseSensitive); 071 072 public boolean conceptualTypeInIdentifierEqualsFauxHyponymyOfSimpleNameOfType(I id, TB type, boolean caseSensitive); 073 074 public FeatureContainer<QI> getFeaturesRemainingInIdentifierBesidesConceptualTypeOfReferentTypeWithFauxHyponymy( 075 I id, TB type, boolean caseSensitive); 076 077 public PP createPositionForExpression(final E expression, final Predicate<EV> condition, 078 final List<Perspectivation> perspectivations); 079 080 public int getLength(final QI qualifiedIdentifier); 081}