<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema attributeFormDefault="unqualified" 
    elementFormDefault="qualified" 
    targetNamespace="http://bogusnamespace.com/sentence_info" 
    xmlns:si="http://bogusnamespace.com/sentence_info" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <!-- First define the non-trivial field types -->
    <!-- ID -->
    <xsd:simpleType name="idType">
        <xsd:restriction base="xsd:string"></xsd:restriction>
    </xsd:simpleType>
    <!-- Version Number -->
    <!-- this can be used during development to determine if all fields are up do date with the most current versions -->
    <xsd:simpleType name="versionType">
        <xsd:restriction base="xsd:string"></xsd:restriction>
    </xsd:simpleType>
    <!-- Sentence -->
    <xsd:simpleType name="sentenceType">
        <xsd:restriction base="xsd:string"></xsd:restriction>
    </xsd:simpleType>
    <!-- Word Sense-->
    <xsd:simpleType name="wordSenseType">
        <xsd:restriction base="xsd:integer"/>
    </xsd:simpleType>
    <!-- Part of Speech -->
    <xsd:simpleType name="posType">
            <xsd:restriction base="xsd:string"/>
        </xsd:simpleType>
    <!-- Stem -->
    <xsd:simpleType name="stemType">
            <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
    <!-- Cost Magnification Factor -->
    <xsd:simpleType name="costMagType">
        <xsd:restriction base="xsd:float"/>
    </xsd:simpleType>
    <!-- Typed Dependency -->
    <!-- this is currently underdefined -->
    <xsd:complexType name="typedDepType">
        <xsd:sequence>
            <xsd:element name="typedDep" type="si:depType"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <!-- Name Entity Recognition -->
    <xsd:complexType name="nerType">
        <xsd:sequence>
            <xsd:element name="nerID" type="xsd:integer" minOccurs="0"></xsd:element>
            <xsd:element name="nerLabel" type="xsd:string" minOccurs="0"></xsd:element>
            <xsd:element name="nerTag" type="xsd:string" minOccurs="0"></xsd:element>
            <xsd:element name="normalized" type="xsd:string" minOccurs="0"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <!-- Word Entry -->
    <xsd:complexType name="wordType">
        <xsd:sequence>
            <xsd:element name="word" type="xsd:string"></xsd:element>
            <xsd:element name="wordSense" type="si:wordSenseType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
            <xsd:element name="pos" type="si:posType" minOccurs="0"></xsd:element>
            <xsd:element name="stem" type="si:stemType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
            <xsd:element name="costMagnification" type="si:costMagType" minOccurs="0"></xsd:element>
            <xsd:element name="nerInfo" type="si:nerType" minOccurs="0"></xsd:element>
        </xsd:sequence>
        <xsd:attribute name="ID" type="si:idType"></xsd:attribute>
    </xsd:complexType>
    <!-- Parse -->
    <!-- this is currently understructured -->
    <xsd:simpleType name="parseType">
        <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
    <!-- Single Dependency -->
    <xsd:complexType name="depType">
        <xsd:sequence>
            <xsd:element name="relation" type="xsd:string"/>
            <xsd:element name="governor" type="xsd:string"/>
            <xsd:element name="dependent" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    <!-- Dependency Parse -->
    <xsd:complexType name="depParseType">
        <xsd:sequence>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="dependency" type="si:depType"></xsd:element>
        </xsd:sequence>
        <xsd:attribute name="version" type="si:versionType"></xsd:attribute>
    </xsd:complexType>
    <!-- Semantic Role Labeling -->
    <!-- each sentenceInfo has an srlTable containing srlType elements -->
 <xsd:complexType name="srlTableType">
        <xsd:sequence>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="srl" type="si:srlType"></xsd:element>
        </xsd:sequence>
        <xsd:attribute name="version" type="si:versionType"></xsd:attribute>
    </xsd:complexType>
    <xsd:complexType name="srlType">
        <xsd:sequence>
            <xsd:element name="label" type="xsd:string" minOccurs="1" maxOccurs ="1" />
             <xsd:element name="predicate" type="xsd:string" minOccurs="1" maxOccurs ="1" />
 <xsd:element name="argument" type="xsd:string" minOccurs="1" maxOccurs ="1" />
        </xsd:sequence>
     
    </xsd:complexType>
    <!-- Coreferences -->
    <!-- this is underdefined currently -->
    <xsd:complexType name="coRefType">
        <xsd:sequence>
            <xsd:element name="word1ID" type="xsd:string"/>
            <xsd:element name="word2ID" type="xsd:string"/>
        </xsd:sequence>
        <xsd:attribute name="word1SentID" type="xsd:string"/>
        <xsd:attribute name="word2SentID" type="xsd:string"/>
    </xsd:complexType>
    <!-- Argument -->
    <!-- this is an argument for the arglist in the logical form -->
    <xsd:complexType name="argType">
        <xsd:sequence>
            <xsd:element name="argRefNumber" type="xsd:integer"></xsd:element>
            <xsd:element name="srl" type="si:srlType" minOccurs="0"></xsd:element>
            <xsd:element name="typedDep" type="si:typedDepType" minOccurs="0"></xsd:element>
        </xsd:sequence>
         <xsd:attribute name="id" type="xsd:string"/>
    </xsd:complexType>
   <!-- Word Table -->
    <xsd:complexType name="wordTableType">
        <xsd:sequence>
            <xsd:element name="wordInfo" type="si:wordType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <!-- Single Word in Logical Form -->
    <!-- contains a word and it's args -->
    <xsd:complexType name="wArgsType">
        <xsd:sequence>
            <xsd:element name="word" type="si:wordType"></xsd:element>
            <xsd:element name="argument" type="si:argType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <!-- Logical Form -->
    <!-- this is currently underdefined, but contains each predicate/word, the information about that word as contained 
    in the wordType and the argument list for that word - one could leave out the information about the word other than
    the id number and use that number to find the word in the word table -->
    <xsd:complexType name="logicalFormType">
        <xsd:sequence>
            <xsd:element name="term" type="si:wArgsType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
        </xsd:sequence>
        <xsd:attribute name="version" type="si:versionType"></xsd:attribute>
    </xsd:complexType>    
    <!-- Aria Graph Form -->
    <!-- this is currently underdefined, but intended to provide space for the graph matching prover -->
    <xsd:complexType name="graphFormType">
        <xsd:sequence>
            <xsd:element name="graphElement" type="xsd:string" minOccurs="0" maxOccurs="unbounded"></xsd:element>
        </xsd:sequence>
        <xsd:attribute name="version" type="si:versionType"></xsd:attribute>
    </xsd:complexType>
    <!-- Sentence Info Structure -->
    <!-- this incorporates all of the previous types into a type -->
    <!-- version number indicates what version of the RTE engine was used to create all fields
        except logicalForm and graphMatchForm.  these fields have their own version numbers that
        may differ from the global version number -->
    <xsd:complexType name="sentInfoType">
        <xsd:sequence>
            <xsd:element name="sentence" type="si:sentenceType" minOccurs="0"></xsd:element>
            <xsd:element name="wordTable" type="si:wordTableType" minOccurs="0"></xsd:element>
            <xsd:element name="parse" type="si:parseType" minOccurs="0"></xsd:element>
            <xsd:element name="dependencyParse" type="si:depParseType" minOccurs="0"></xsd:element>
            <xsd:element name="srlTable" type="si:srlTableType" minOccurs="0"></xsd:element>
            <xsd:element name="coreference" type="si:coRefType" minOccurs="0"></xsd:element>
            <xsd:element name="logicalForm" type="si:logicalFormType" minOccurs="0"></xsd:element>
            <xsd:element name="graphMatchForm" type="si:graphFormType" minOccurs="0"></xsd:element>
        </xsd:sequence>
        <xsd:attribute name="id" type="si:idType"/>
        <xsd:attribute name="version" type="si:versionType"></xsd:attribute>
    </xsd:complexType>

    <!-- Field for a sentence and its ID. -->
    <xsd:complexType name="passageType">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="id" type="xsd:string" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>
    
    <!-- Document Info wrapper -->
    <xsd:complexType name="docInfoType">
        <xsd:sequence>
            <xsd:element name="passage" type="si:passageType" minOccurs="0"/>
            <xsd:element name="sentenceInfo" type="si:sentInfoType" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="globalCorefs" type="si:coRefType" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="questionType" type="xsd:string"/>
    </xsd:complexType>
    <!-- Root -->
    <!-- simply allows 0-unbounded sentence infos, global coreferences, and the original passage to appear -->
    <xsd:element name="root">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="docInfo" type="si:docInfoType"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

