001 // This file is part of the Attempto Java Packages.
002 // Copyright 2008, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch).
003 //
004 // The Attempto Java Packages is free software: you can redistribute it and/or modify it under the
005 // terms of the GNU Lesser General Public License as published by the Free Software Foundation,
006 // either version 3 of the License, or (at your option) any later version.
007 //
008 // The Attempto Java Packages is distributed in the hope that it will be useful, but WITHOUT ANY
009 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
010 // PURPOSE. See the GNU Lesser General Public License for more details.
011 //
012 // You should have received a copy of the GNU Lesser General Public License along with the Attempto
013 // Java Packages. If not, see http://www.gnu.org/licenses/.
014
015 package ch.uzh.ifi.attempto.preditor.example;
016
017 import ch.uzh.ifi.attempto.chartparser.Terminal;
018 import ch.uzh.ifi.attempto.preditor.MenuCreator;
019 import ch.uzh.ifi.attempto.preditor.text.BasicTextElement;
020 import ch.uzh.ifi.attempto.preditor.text.NounTextElement;
021
022 /**
023 * This class is an examplary implementation of a menu creator. See the
024 * <a href="{@docRoot}/src-html/ch/uzh/ifi/attempto/preditor/example/ExampleMenuCreator.html#line.1">source code</a>.
025 *
026 * @author Tobias Kuhn
027 */
028 public class ExampleMenuCreator extends MenuCreator {
029
030 /**
031 * Creates a new menu creator instance.
032 */
033 public ExampleMenuCreator() {
034 }
035
036 public void initMenuCreation() {
037 // Here we can define the order of the menu blocks and whether they should be sorted or not:
038 prepareMenuBlock("function word", true);
039 prepareMenuBlock("determiner", true);
040 prepareMenuBlock("noun", true);
041 prepareMenuBlock("proper name", true);
042 prepareMenuBlock("intransitive verb", true);
043 prepareMenuBlock("transitive verb", true);
044 }
045
046 public void processCategory(Terminal category) {
047 String n = category.getName();
048
049 if (n.equals("DET")) {
050 addMenuEntry("determiner", new BasicTextElement("a", n));
051 addMenuEntry("determiner", new BasicTextElement("no", n));
052 addMenuEntry("determiner", new BasicTextElement("every", n));
053 } else if (n.equals("N")) {
054 addMenuEntry("noun", new NounTextElement("man", n));
055 addMenuEntry("noun", new NounTextElement("woman", n));
056 addMenuEntry("noun", new NounTextElement("human", n));
057 addMenuEntry("noun", new NounTextElement("dog", n));
058 addMenuEntry("noun", new NounTextElement("house", n));
059 addMenuEntry("noun", new NounTextElement("car", n));
060 } else if (n.equals("PN")) {
061 addMenuEntry("proper name", new BasicTextElement("John", n));
062 addMenuEntry("proper name", new BasicTextElement("Bill", n));
063 addMenuEntry("proper name", new BasicTextElement("Mary", n));
064 addMenuEntry("proper name", new BasicTextElement("Sue", n));
065 addMenuEntry("proper name", new BasicTextElement("Tom", n));
066 addMenuEntry("proper name", new BasicTextElement("Rick", n));
067 addMenuEntry("proper name", new BasicTextElement("Paul", n));
068 } else if (n.equals("IV")) {
069 addMenuEntry("intransitive verb", new BasicTextElement("waits", n));
070 addMenuEntry("intransitive verb", new BasicTextElement("sleeps", n));
071 addMenuEntry("intransitive verb", new BasicTextElement("works", n));
072 addMenuEntry("intransitive verb", new BasicTextElement("eats", n));
073 addMenuEntry("intransitive verb", new BasicTextElement("drinks", n));
074 } else if (n.equals("TV")) {
075 addMenuEntry("transitive verb", new BasicTextElement("sees", n));
076 addMenuEntry("transitive verb", new BasicTextElement("knows", n));
077 addMenuEntry("transitive verb", new BasicTextElement("owns", n));
078 addMenuEntry("transitive verb", new BasicTextElement("uses", n));
079 addMenuEntry("transitive verb", new BasicTextElement("buys", n));
080 addMenuEntry("transitive verb", new BasicTextElement("sells", n));
081 addMenuEntry("transitive verb", new BasicTextElement("drives", n));
082 addMenuEntry("transitive verb", new BasicTextElement("likes", n));
083 } else if (n.equals("REF")) {
084 addReferenceEntries("reference", n);
085 } else if (n.equals("VAR")) {
086 addVariableEntries("variable", 10, n);
087 } else {
088 addMenuEntry("function word", new BasicTextElement(n));
089 }
090 }
091
092 }