001 package edu.upenn.cis.propbank_shen;
002
003 import java.util.LinkedList;
004 import java.util.List;
005
006 import java.util.LinkedList;
007 import java.util.List;
008
009 import org.w3c.dom.Node;
010 import org.w3c.dom.NamedNodeMap;
011 import org.w3c.dom.Attr;
012
013 /**
014 This class represents an example in the lexical guidelines.
015
016 An example consists of some text together with an optional
017 name and a list of arguments for the verb described in the
018 frameset file of which this example is a part.
019 @author Scott Cotton
020
021
022 */
023 public class Example {
024
025 protected Node node;
026 protected String name;
027
028 protected String text;
029 protected List arguments;
030
031 /** construct an Example object from a dom example Node in the frameset.dtd */
032 public Example(Node n)
033 {
034 node = n;
035 arguments = null;
036 name = null;
037 NamedNodeMap attrs = n.getAttributes();
038 int len = attrs.getLength();
039 String anm = null;
040 for(int i=0; i<len; i++) {
041 Attr attr = (Attr) attrs.item(i);
042 anm = attr.getNodeName();
043 if (anm.equals("name")) {
044 name = (String) attr.getNodeValue();
045 }
046 }
047 // find the text node
048 text = null;
049 Node nc = node.getFirstChild();
050 while (nc != null) {
051 if (nc.getNodeName().equals("text")) {
052 text = (String) nc.getFirstChild().getNodeValue();
053 break;
054 }
055 nc = nc.getNextSibling();
056 }
057 }
058
059 /** return truee iff this example has a name */
060 public boolean hasName()
061 {
062 return name != null;
063 }
064
065
066 /** get the name of this example, or return null if there is no name */
067 public String getName()
068 {
069 return name;
070 }
071
072
073
074 /** return the example text as a string. */
075 public String getText()
076 {
077 return text;
078 }
079 }