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.acewiki.aceowl;
016
017 import ch.uzh.ifi.attempto.acewiki.core.Sentence;
018 import ch.uzh.ifi.attempto.acewiki.core.SentenceSuggestion;
019
020 /**
021 * This class implements a change suggestions for ACE sentences starting with "a". Such sentences
022 * are usually meant to invoke universal quantification. In such cases the initial "a" should be
023 * replaced by "every".
024 *
025 * @author Tobias Kuhn
026 */
027 public class AToEverySuggestion implements SentenceSuggestion {
028
029 private ACESentence sentence;
030
031 AToEverySuggestion(ACESentence sentence) {
032 this.sentence = sentence;
033 }
034
035 public String getMessage() {
036 String s = sentence.getTextElements().get(1).getText();
037 return "Your sentence \"a " + s + " ...\" is interpreted as \"there is a " + s +
038 " that ...\". Do you want to say \"every " + s + " ...\"?";
039 }
040
041 public String[] getOptions() {
042 return new String[] {"a ...", "every ..."};
043 }
044
045 public Sentence getSentence(String option) {
046 if (option.equals("every ...")) {
047 String text = sentence.getText();
048 text = text.replaceFirst("^(A|a)n? ", "Every ");
049 return sentence.getOntology().getStatementFactory().createSentence(
050 text,
051 sentence.getArticle()
052 );
053 }
054 return sentence;
055 }
056
057 }