001    // This file is part of AceWiki.
002    // Copyright 2008-2012, AceWiki developers.
003    // 
004    // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU
005    // Lesser General Public License as published by the Free Software Foundation, either version 3 of
006    // the License, or (at your option) any later version.
007    // 
008    // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009    // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
010    // Lesser General Public License for more details.
011    // 
012    // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If
013    // not, see http://www.gnu.org/licenses/.
014    
015    package ch.uzh.ifi.attempto.base;
016    
017    import java.util.List;
018    
019    /**
020     * This interface defines text operations that are needed by the predictive editor.
021     * 
022     * @author Tobias Kuhn
023     */
024    public interface TextOperator {
025            
026            /**
027             * This method should split a text into its tokens.
028             * 
029             * @param text The input text.
030             * @return A list of strings representing the tokens.
031             */
032            public List<String> splitIntoTokens(String text);
033            
034            /**
035             * This method checks the context of a text element and can do small surface adaptations of a
036             * token according to the surrounding text. E.g. in English "a" should become "an" in front
037             * of "apple".
038             * 
039             * @param textElement The text element whose text should be adapted to the context.
040             * @param preceding The preceding text.
041             * @param following The following text.
042             * @return The adapted text.
043             */
044            public String getTextInContext(TextElement textElement, String preceding, String following);
045            
046            /**
047             * This method should create a text element for the given text.
048             * 
049             * @param text The text.
050             * @return The text element.
051             */
052            // TODO This method should be able to return multiple possibilities.
053            public TextElement createTextElement(String text);
054            
055            /**
056             * This method should return the "glue" to connect two text elements. Mostly, this should be a
057             * single blank space or the empty string.
058             * 
059             * @param left The left-hand side text element.
060             * @param right The right-hand side text element.
061             * @return The glue string.
062             */
063            public String getGlue(TextElement left, TextElement right);
064    
065    }