<!-- Copyright (C) 2017–2019, Kevin Brubeck Unhammer <unhammer@fsfe.org> -->

<!-- This program is free software: you can redistribute it and/or modify -->
<!-- it under the terms of the GNU General Public License as published by -->
<!-- the Free Software Foundation, either version 3 of the License, or -->
<!-- (at your option) any later version. -->

<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -->
<!-- GNU General Public License for more details. -->

<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program.  If not, see <http://www.gnu.org/licenses/>. -->

<!--
-->

<!-- Root element:-->
<!ELEMENT pipespec (pipeline+)>
<!ATTLIST pipespec
          language CDATA #REQUIRED
          developer CDATA #IMPLIED
          copyright CDATA #IMPLIED
          contact CDATA #IMPLIED
          version CDATA #IMPLIED
          depversions CDATA #IMPLIED
          default-pipe CDATA #IMPLIED
          >
<!--
== pipespec attributes ==
  language:    BCP-47, default language code for pipelines in this spec
  contact:     typically an e-mail address
  version:     version of this module
  depversions: versions of sub-modules used by the pipeline, e.g. hfst
 -->

<!ELEMENT pipeline (prefs?, (sh|cg|cgspell|tokenize|tokenise|mwesplit|blanktag|suggest)+)>
<!ATTLIST pipeline
          name ID #REQUIRED
          language CDATA #IMPLIED
          type CDATA #IMPLIED
          >
<!--
== pipeline attributes ==
  name:        user-readable, but unique name of the pipeline
  language:    BCP-47, may override the language code of the pipespec
 -->

<!ELEMENT prefs (pref+)>

<!ELEMENT pref (option+)>
<!ATTLIST pref
          type CDATA #REQUIRED
          name CDATA #REQUIRED
>
<!-- type and name are *not* unique here; several pipelines may have a pref for e.g. "Oxford comma" -->


<!ELEMENT option ((label|description)+)>
<!ATTLIST option
          err-id CDATA #REQUIRED
>

<!ENTITY % Text "(#PCDATA | em)*">

<!ELEMENT label %Text;>
<!ATTLIST label
          xml:lang CDATA #REQUIRED
>

<!ELEMENT description %Text;>
<!ATTLIST description
          xml:lang CDATA #REQUIRED
>

<!-- General "system" command – pipelines with this can only be used
     in settings where we can open processes: -->
<!ELEMENT sh (arg*)> <!-- NOT IMPLEMENTED YET -->
<!ATTLIST sh
          prog CDATA #REQUIRED
>

<!-- Library-based commands – no IPC/process open() required since
     these just use linked libraries: -->
<!ELEMENT cg (grammar)>           <!-- arg: grammar.cg3 -->
<!ELEMENT cgspell ((lexicon, errmodel)|(errmodel, lexicon))> <!-- arg1: acceptor.hfstol, arg2: errmodel.hfst -->
<!ATTLIST cgspell
          limit CDATA "10"
          beam CDATA "15.0"
          max-weight CDATA "5000.0"
          max-unknown-rate CDATA "0.4">
<!ELEMENT tokenize (tokenizer)>     <!-- arg: tokeniser.pmhfst -->
<!ELEMENT tokenise (tokenizer)>     <!-- en_GB alias of the above -->
<!ATTLIST tokenize
          weight-classes CDATA #IMPLIED> <!-- no limit if not specified -->
<!ATTLIST tokenise
          weight-classes CDATA #IMPLIED> <!-- no limit if not specified -->
<!ELEMENT mwesplit EMPTY>     <!-- takes no arguments -->
<!ELEMENT blanktag (blanktagger)> <!-- arg: blanktagger.hfst -->
<!ELEMENT suggest ((generator, messages)|(messages, generator))> <!-- arg1: generator.hfstol, arg2: error_messages.xml -->
<!ATTLIST suggest
          generate-all (true|false) "false">
<!ELEMENT normalise (normaliser,analyser,generator,tags)>
<!ELEMENT normalize (normaliser,analyser,generator,tags)> <!-- en_US variant of above -->
<!ELEMENT phon (text2ipa,alttext2ipa*)> <!-- arg: text2ipa.hfst -->

<!-- Is there a way to generalize over these apart from shifting to <arg key=… val=…>? -->
<!ELEMENT arg EMPTY>         <!ATTLIST arg n CDATA #REQUIRED>
<!ELEMENT grammar EMPTY>     <!ATTLIST grammar n CDATA #REQUIRED>
<!ELEMENT lexicon EMPTY>     <!ATTLIST lexicon n CDATA #REQUIRED>
<!ELEMENT errmodel EMPTY>    <!ATTLIST errmodel n CDATA #REQUIRED>
<!ELEMENT tokenizer EMPTY>   <!ATTLIST tokenizer n CDATA #REQUIRED>
<!ELEMENT blanktagger EMPTY> <!ATTLIST blanktagger n CDATA #REQUIRED>
<!ELEMENT generator EMPTY>   <!ATTLIST generator n CDATA #REQUIRED>
<!ELEMENT messages EMPTY>    <!ATTLIST messages n CDATA #REQUIRED>
<!ELEMENT normaliser EMPTY>  <!ATTLIST normaliser n CDATA #REQUIRED>
<!ELEMENT analyser EMPTY>    <!ATTLIST analyser n CDATA #REQUIRED>
<!ELEMENT text2ipa EMPTY>    <!ATTLIST text2ipa n CDATA #REQUIRED>
<!ELEMENT alttext2ipa EMPTY> <!ATTLIST alttext2ipa s CDATA #REQUIRED n CDATA #REQUIRED>
<!ELEMENT tags (tag+)>
<!ELEMENT tag EMPTY>         <!ATTLIST tag n CDATA #REQUIRED>
