001 // This file is part of the Attempto Java Packages. 002 // Copyright 2008-2009, 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.Restriction; 018 import ch.uzh.ifi.attempto.preditor.MenuCreator; 019 import ch.uzh.ifi.attempto.preditor.text.TextElement; 020 021 /** 022 * This class is an examplary implementation of a menu creator. See the 023 * <a href="{@docRoot}/src-html/ch/uzh/ifi/attempto/preditor/example/ExampleMenuCreator.html#line.1">source code</a>. 024 * 025 * @author Tobias Kuhn 026 */ 027 public class ExampleMenuCreator extends MenuCreator { 028 029 /** 030 * Creates a new menu creator instance. 031 */ 032 public ExampleMenuCreator() { 033 } 034 035 public void initMenuCreation() { 036 // Here we can define the order of the menu blocks and whether they should be sorted or not: 037 prepareMenuBlock("function word", true); 038 prepareMenuBlock("determiner", true); 039 prepareMenuBlock("noun", true); 040 prepareMenuBlock("proper name", true); 041 prepareMenuBlock("intransitive verb", true); 042 prepareMenuBlock("transitive verb", true); 043 } 044 045 public void addMenuItems(Restriction restriction) { 046 String n = restriction.getCategory().getName(); 047 048 if (n.equals("DET")) { 049 addMenuEntry("determiner", new TextElement("a", n)); 050 addMenuEntry("determiner", new TextElement("no", n)); 051 addMenuEntry("determiner", new TextElement("every", n)); 052 } else if (n.equals("N")) { 053 addMenuEntry("noun", new TextElement("man", n)); 054 addMenuEntry("noun", new TextElement("woman", n)); 055 addMenuEntry("noun", new TextElement("human", n)); 056 addMenuEntry("noun", new TextElement("dog", n)); 057 addMenuEntry("noun", new TextElement("house", n)); 058 addMenuEntry("noun", new TextElement("car", n)); 059 } else if (n.equals("PN")) { 060 addMenuEntry("proper name", new TextElement("John", n)); 061 addMenuEntry("proper name", new TextElement("Bill", n)); 062 addMenuEntry("proper name", new TextElement("Mary", n)); 063 addMenuEntry("proper name", new TextElement("Sue", n)); 064 addMenuEntry("proper name", new TextElement("Tom", n)); 065 addMenuEntry("proper name", new TextElement("Rick", n)); 066 addMenuEntry("proper name", new TextElement("Paul", n)); 067 } else if (n.equals("IV")) { 068 addMenuEntry("intransitive verb", new TextElement("waits", n)); 069 addMenuEntry("intransitive verb", new TextElement("sleeps", n)); 070 addMenuEntry("intransitive verb", new TextElement("works", n)); 071 addMenuEntry("intransitive verb", new TextElement("eats", n)); 072 addMenuEntry("intransitive verb", new TextElement("drinks", n)); 073 } else if (n.equals("TV")) { 074 addMenuEntry("transitive verb", new TextElement("sees", n)); 075 addMenuEntry("transitive verb", new TextElement("knows", n)); 076 addMenuEntry("transitive verb", new TextElement("owns", n)); 077 addMenuEntry("transitive verb", new TextElement("uses", n)); 078 addMenuEntry("transitive verb", new TextElement("buys", n)); 079 addMenuEntry("transitive verb", new TextElement("sells", n)); 080 addMenuEntry("transitive verb", new TextElement("drives", n)); 081 addMenuEntry("transitive verb", new TextElement("likes", n)); 082 } else { 083 addMenuEntry("function word", new TextElement(n)); 084 } 085 } 086 087 }