static boolean acceptsInternal(DependencyPath path) {
        // First check whether the minimum template acceptor would allow this
        // path
        if (MinimumMiniparTemplateAcceptor.acceptsInternal(path))
            return true;

        // Filter out paths that can't match the template due to length
        if (path.length() > 3)
            return false;

        int pathLength = path.length();

        // The medium set of templates contains "null" matches which are wild
        // cards against any part of speech.  We handle these by generating
        // three possible patterns that could represent the provided path.  If
        // any of these patterns are found in the medium set, the path is valid.
        StringBuilder nullStart = new StringBuilder(pathLength * 16);
        StringBuilder nullEnd = new StringBuilder(pathLength * 16);
        StringBuilder noNulls = new StringBuilder(pathLength * 16);

        // Iterate over each pair in the path and create the pattern string that
        // represents this path.  The pattern string is pos:rel:pos[,...] .
        DependencyTreeNode first = path.first();
        for (int i = 1; i < pathLength; ++i) {
            DependencyTreeNode second = path.getNode(i);
            // Check that the nodes weren't filtered out.  If so reject the path
            // even if the part of speech and relation text may have matched a
            // template.
            if (first.word().equals(IteratorFactory.EMPTY_TOKEN))
                return false;

            // Get the relation between the two nodes
            String rel = path.getRelation(i - 1);
            String firstPos = first.pos();
            String secPos = second.pos();
            
            nullStart.append((i == 0) ? "(null)" : firstPos);
            nullStart.append(":").append(rel).append(":").append(secPos);

            nullEnd.append(firstPos).append(":").append(rel).append(":");
            nullEnd.append((i + 1 == pathLength) ? "(null)" : secPos);

            noNulls.append(firstPos).append(":").append(rel)
                .append(":").append(secPos);

            // Check whether more elements existing, and if so, add the ','
            if (i + 1 < pathLength) {
                nullStart.append(",");
                nullEnd.append(",");
                noNulls.append(",");
            }

            // Last, shift over the node
            first = second;
        }
        
        // Extra case for the last token in the path
        if (first.word().equals(IteratorFactory.EMPTY_TOKEN))
            return false;

        return MEDIUM_TEMPLATES.contains(noNulls.toString())
            || MEDIUM_TEMPLATES.contains(nullStart.toString())
            || MEDIUM_TEMPLATES.contains(nullEnd.toString());
    }
static boolean acceptsInternal ( DependencyPath path ) { if ( MinimumMiniparTemplateAcceptor . acceptsInternal ( path ) ) return true ; if ( path . length ( ) > 3 ) return false ; int pathLength = path . length ( ) ; StringBuilder nullStart = new StringBuilder ( pathLength * 16 ) ; StringBuilder nullEnd = new StringBuilder ( pathLength * 16 ) ; StringBuilder noNulls = new StringBuilder ( pathLength * 16 ) ; DependencyTreeNode first = path . first ( ) ; for ( int i = 1 ; i < pathLength ; ++ i ) { DependencyTreeNode second = path . getNode ( i ) ; if ( first . word ( ) . equals ( IteratorFactory . EMPTY_TOKEN ) ) return false ; String rel = path . getRelation ( i - 1 ) ; String firstPos = first . pos ( ) ; String secPos = second . pos ( ) ; nullStart . append ( ( i == 0 ) ? "(null)" : firstPos ) ; nullStart . append ( ":" ) . append ( rel ) . append ( ":" ) . append ( secPos ) ; nullEnd . append ( firstPos ) . append ( ":" ) . append ( rel ) . append ( ":" ) ; nullEnd . append ( ( i + 1 == pathLength ) ? "(null)" : secPos ) ; noNulls . append ( firstPos ) . append ( ":" ) . append ( rel ) . append ( ":" ) . append ( secPos ) ; if ( i + 1 < pathLength ) { nullStart . append ( "," ) ; nullEnd . append ( "," ) ; noNulls . append ( "," ) ; } first = second ; } if ( first . word ( ) . equals ( IteratorFactory . EMPTY_TOKEN ) ) return false ; return MEDIUM_TEMPLATES . contains ( noNulls . toString ( ) ) || MEDIUM_TEMPLATES . contains ( nullStart . toString ( ) ) || MEDIUM_TEMPLATES . contains ( nullEnd . toString ( ) ) ; }
A package-private method that checks whether the path matches any of the
predefined templates.  This method is provided so other template classes
have access to the accept logic used by this class.

@param path a dependency path

@return {@code true} if the path matches a template