Class SequentialAxe

  • All Implemented Interfaces:
    Axe

    public class SequentialAxe
    extends java.lang.Object
    implements Axe
    An Axe that returns ever tree in the forest.
    • Constructor Summary

      Constructors 
      Constructor Description
      SequentialAxe()
      Create a sequential axe that does not avoid loops.
      SequentialAxe​(boolean avoidLoops)
      Create a sequential axe.
    • Constructor Detail

      • SequentialAxe

        public SequentialAxe()
        Create a sequential axe that does not avoid loops.
      • SequentialAxe

        public SequentialAxe​(boolean avoidLoops)
        Create a sequential axe.
        Parameters:
        avoidLoops - if true, avoid loops.
    • Method Detail

      • isSpecialist

        public boolean isSpecialist()
        Description copied from interface: Axe
        Is this a specialist axe?

        A specialist axe can consider every tree in the forest differently every time it is used. A non-specialist axe considers every tree at most once and returns all the trees that are selected.

        Specified by:
        isSpecialist in interface Axe
        Returns:
        true if the axe is specialist
      • select

        public java.util.List<Family> select​(ParseTree tree,
                                             ForestNode forestNode,
                                             int count,
                                             java.util.List<Family> choices)
        Description copied from interface: Axe
        Select a branch from a list of branches.

        In an ambiguous forest, some nodes will have more than one possible choice. In any given tree, only one choice may be selected. This function is called to make the selection.

        There will always be at least one element in the choices list when the method is called. The method must return at least one. If only one choice is returned, the node becomes unambiguous on subsequent parses, the same selection will always be used.

        When used by a Lumberjack, all of the selections returned will be considered for sequential parses. No duplicates are allowed.

        When used by a TreeSurgeon, the first node in the list returned is the choice selected for the tree currently under construction. If additional choices are returned, they will be considered on subsequent parses. Note that if you want the selected choice to be considered on future parses, it must appear in the list twice. It is the only node that may appear twice.

        Specified by:
        select in interface Axe
        Parameters:
        tree - the parent node in the parse tree
        forestNode - the forest node
        count - the number of times node has occurred in this parse
        choices - the possible paths
        Returns:
        the acceptable paths
      • wasAmbiguousSelection

        public boolean wasAmbiguousSelection()
        Description copied from interface: Axe
        Was the previous selection ambiguous?

        This method asks if the previous selection was ambiguous. If the axe ever indicates that an ambiguous selection was made, the resulting parse is considered ambiguous. For example, the SequentialAxe always returns true because it treats all choices as equivalent. The PriorityAxe only considers a selection ambiguous if there wasn't a uniquely highest priority selection.

        Specified by:
        wasAmbiguousSelection in interface Axe
        Returns:
        true if the choice made was random
      • forArborist

        public void forArborist​(Arborist arborist)
        Description copied from interface: Axe
        Who's using this axe?

        Do not pass the same axe to more than one Arborist.

        Specified by:
        forArborist in interface Axe
        Parameters:
        arborist - the Arborist using this axe.