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 java.util.ArrayList; 018 import java.util.Collection; 019 import java.util.List; 020 021 import ch.uzh.ifi.attempto.acewiki.owl.OWLRelation; 022 import ch.uzh.ifi.attempto.ape.Gender; 023 import ch.uzh.ifi.attempto.ape.LexiconEntry; 024 import ch.uzh.ifi.attempto.chartparser.LexicalRule; 025 026 /** 027 * This class stands for relations that are represented by of-constructs in ACE and object 028 * properties in OWL. Of-constructs consist of a noun plus the word "of". They have only one word 029 * form. 030 *<p> 031 * 0: word form consisting of a noun plus the word "of". 032 *<p> 033 * Examples: "father of"; "part of". 034 * 035 * @author Tobias Kuhn 036 */ 037 public class OfRelation extends OWLRelation implements ACEOWLOntoElement { 038 039 private String word; 040 041 /** 042 * Creates a new relation that is represented by an of-construct. 043 */ 044 public OfRelation() { 045 } 046 047 public String[] getWords() { 048 return new String[] {word}; 049 } 050 051 public void setWords(String serializedWords) { 052 String[] words = serializedWords.split(";"); 053 word = words[0]; 054 if (!words[0].endsWith(" of")) { 055 word = word + " of"; 056 } 057 } 058 059 public String serializeWords() { 060 return word + ";"; 061 } 062 063 /** 064 * Returns the noun of the of-construct. 065 * 066 * @return The noun. 067 */ 068 public String getNoun() { 069 if (word == null) { 070 return null; 071 } else { 072 return word.substring(0, word.length()-3); 073 } 074 } 075 076 public String getIRISuffix() { 077 return getNoun(); 078 } 079 080 public List<LexiconEntry> getLexiconEntries() { 081 List<LexiconEntry> entries = new ArrayList<LexiconEntry>(); 082 if (word != null) { 083 entries.add(LexiconEntry.createNounSgEntry(getNoun(), getNoun(), Gender.UNDEF)); 084 } 085 return entries; 086 } 087 088 public String getType() { 089 return "Of-Construct"; 090 } 091 092 public String getInternalType() { 093 return "nounof"; 094 } 095 096 public void collectLexicalRules(String catName, Collection<LexicalRule> lexRules) { 097 if (catName == null || catName.equals("nounof")) { 098 lexRules.add(new LexicalRule("nounof", getWord(0))); 099 } 100 } 101 102 }