\change_inserted -712698321 1559649291
interlinear
\change_unchanged
-glosses, OT tableaux, semantic markup, structure trees, and phonetic symbols
- (IPA).
+glosses, OT tableaux, semantic markup, structure trees,
+\change_inserted -712698321 1561275938
+Discourse Representation Structures,
+\change_unchanged
+and phonetic symbols (IPA).
\end_layout
\begin_layout Section
\end_inset
.
+\change_inserted -712698321 1561275950
+
\end_layout
\end_deeper
\end_inset
.
+\change_inserted -712698321 1561276155
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\change_inserted -712698321 1561276156
+
+\emph on
+drs.sty
+\emph default
+
+\begin_inset CommandInset citation
+LatexCommand cite
+key "drs"
+literal "true"
+
+\end_inset
+
+: Needed for
+\emph on
+Discourse Representation Structures
+\emph default
+.
+ Note that at least version 2.3 of the covington package is required if you
+ use DRS with covington features.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+
+\change_inserted -712698321 1561276156
+Installed on your system:
+\begin_inset Info
+type "package"
+arg "drs"
+\end_inset
+
+.
+\change_unchanged
+
\end_layout
\end_deeper
\end_inset
.
+\change_inserted -712698321 1561276162
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\change_inserted -712698321 1561276195
+
+\emph on
+pict2e.sty
+\emph default
+
+\begin_inset CommandInset citation
+LatexCommand cite
+key "pict2e"
+literal "true"
+
+\end_inset
+
+: Needed for
+\emph on
+Duplex Condition DRS
+\emph default
+es.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+
+\change_inserted -712698321 1561276163
+Installed on your system:
+\begin_inset Info
+type "package"
+arg "pict2e"
+\end_inset
+
+.
+\change_unchanged
+
\end_layout
\end_deeper
\end_layout
\begin_layout Section
-Phonetic Symbols (IPA)
-\end_layout
-\begin_layout Standard
-You do not need the Linguistics module to insert phonetic symbols, this
- is a base functionality of \SpecialChar LyX
-.
- However, since this is frequently used by linguists, we will describe it
- (briefly) in this manual nevertheless.
+\change_inserted -712698321 1561276366
+Discourse Representation Structures
\end_layout
\begin_layout Standard
-If you use traditional \SpecialChar LaTeX
- or PDF\SpecialChar LaTeX
-, a prerequisite to use \SpecialChar LyX
-'s IPA support is
- the \SpecialChar LaTeX
- package
-\emph on
-tipa
-\emph default
-
-\begin_inset CommandInset citation
-LatexCommand cite
-key "tipa"
-literal "true"
-
-\end_inset
-
-, which is automatically loaded by \SpecialChar LyX
- if you follow the procedure described
- below.
- If you use Unicode fonts (i.
-\begin_inset space \thinspace{}
-\end_inset
-e., if you have clicked
-\begin_inset Quotes eld
-\end_inset
-
-Use non-\SpecialChar TeX
- fonts
-\begin_inset Quotes erd
-\end_inset
-
- in
-\family sans
-Document\SpecialChar menuseparator
-Settings\SpecialChar menuseparator
-Fonts
-\family default
-), the package
+\change_inserted -712698321 1561276535
+The linguistics module provides some insets to draw
\emph on
-xunicode
+Discourse Representation Structures
\emph default
- is loaded instead (since
+ (DRSes) in the box notation introduced in
+\noun on
+Hans Kamp
+\noun default
+'s
\emph on
-tipa
+Discourse Representation Theory
\emph default
- does not work in this context).
-
-\begin_inset Foot
-status open
-
-\begin_layout Plain Layout
-See also https://github.com/wspr/fontspec/issues/280 and the discussion in
- docutils-devel (https://www.mail-archive.com/search?l=mid&q=1487664738.2405.6.camel%
-40lyx.org).
+.
+ These insets can be found in
+\family sans
+Insert\SpecialChar menuseparator
+Custom Insets
+\family default
+.
\end_layout
-\end_inset
+\begin_layout Standard
- The
+\change_inserted -712698321 1561282371
+A simple DRS is produced by
+\family sans
+Discourse Representation Structure
+\family default
+.
+ A DRS consists of the
\emph on
-xunicode
+conditions
\emph default
- package emulates the
+, which have to be inserted into the inset directly and the (possibly empty)
+
\emph on
-tipa
+referents
\emph default
- output, but is not perfect at that, so some things might not look as expected.
- Furthermore, you need to take care in this case to use a font that includes
- the IPA glyphs (such as
+ (or
\emph on
-CMU Serif
+universe
\emph default
- or
+ in DRTese), which have to be input in the (automatically inserted)
\emph on
-SIL Doulos
+Referents
\emph default
-).
- You can also specify an extra font only for IPA by adding the following
- to
+ sub-inset.
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561276845
+If it is not inserted, you can also insert it via
\family sans
-Document\SpecialChar menuseparator
-Settings\SpecialChar menuseparator
-LaTeX Preamble
+Insert\SpecialChar menuseparator
+DRS Referents
\family default
-:
+.
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+ Line breaks in conditions need to be done via
+\begin_inset Info
+type "shortcut"
+arg "newline-insert newline"
+\end_inset
+
+.
+ Here is a simple example:
\end_layout
\begin_layout Standard
-\begin_inset listings
-lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}"
-inline false
+
+\change_inserted -712698321 1561277426
+\begin_inset VSpace defskip
+\end_inset
+
+
+\begin_inset Flex DRS
status open
\begin_layout Plain Layout
-
-\backslash
-AtBeginDocument{%
-\end_layout
+\change_inserted -712698321 1561276618
+\begin_inset Argument 1
+status open
\begin_layout Plain Layout
+\change_inserted -712698321 1561276576
+x
+\change_unchanged
-\backslash
-newfontfamily{
-\backslash
-ipafont}{CMU Serif}% or another font
\end_layout
-\begin_layout Plain Layout
+\end_inset
-\backslash
-def
-\backslash
-useTIPAfont{
-\backslash
-ipafont}
\end_layout
\begin_layout Plain Layout
-}
+\change_inserted -712698321 1561277217
+donkey(x)
+\begin_inset Newline newline
+\end_inset
+
+green(x)
+\change_unchanged
+
\end_layout
\end_inset
-Additionally, and independent from which of the above approaches you use,
- if you want to have instant preview, you should have the
-\emph on
-preview-latex
-\emph default
- package
-\begin_inset CommandInset citation
-LatexCommand cite
-key "preview"
-literal "true"
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1561278779
+\begin_inset VSpace defskip
\end_inset
- installed.
+DRSes get some extra spacing for better positioning on the page.
+ The
+\family sans
+unspaced
+\family default
+ variant comes without this extra spacing.
\end_layout
\begin_layout Standard
-The recommended way to insert phonetic symbols is via
+
+\change_inserted -712698321 1561282534
+In addition to this simple DRS, the following conditional DRSes are provided
+ (mainly for nesting into simple DRSes):
+\end_layout
+
+\begin_layout Enumerate
+
+\change_inserted -712698321 1561282617
+The
\family sans
-Insert\SpecialChar menuseparator
-Special characters\SpecialChar menuseparator
-Phonetic symbols.
-
+If-Then DRS
\family default
-This gives you an input box (
-\begin_inset Quotes eld
-\end_inset
+ represents a conditional (implicational) sentence constructions of the
+ form
+\emph on
+if S
+\begin_inset script subscript
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279387
+
+\emph off
+1
+\change_unchanged
+
+\end_layout
-inset
-\begin_inset Quotes erd
\end_inset
- in \SpecialChar LyX
- speak), where you can insert the symbols.
- Note that this box can be used both for the insertion of small snippets
- (inline) and multiple paragraphs of phonetic notation.
- While the cursor is inside the box, a toolbar opens, which provides the
- basic set of phonetic symbols (sorted by the IPA categories).
-\begin_inset Foot
-status collapsed
+ then S
+\emph default
+
+\begin_inset script subscript
\begin_layout Plain Layout
-Currently, there is one symbol missing: the labiodental flap (added to the
+
+\change_inserted -712698321 1561279395
+2
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+
+\change_inserted -712698321 1561279897
+\begin_inset Flex IfThen-DRS
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279544
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280450
+x
+\begin_inset space ~
+\end_inset
+
+y
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280496
+John(x)
+\begin_inset Newline newline
+\end_inset
+
+donkey(y)
+\begin_inset Newline newline
+\end_inset
+
+own(x,y)
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279603
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279599
+z
+\begin_inset space ~
+\end_inset
+
+w
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279579
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280579
+z = x
+\begin_inset Newline newline
+\end_inset
+
+w = y
+\begin_inset Newline newline
+\end_inset
+
+feed(z,w)
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\change_inserted -712698321 1561282668
+The
+\family sans
+Conditional DRS
+\family default
+ is a more general case where you can specify an arbitrary condition (rather
+ than using the implicational condition).
+ You can insert any symbol in the condition sub-inset:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+
+\change_inserted -712698321 1561281161
+\begin_inset Flex Cond-DRS
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280361
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280351
+x
+\begin_inset space ~
+\end_inset
+
+y
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280787
+John(x)
+\begin_inset Newline newline
+\end_inset
+
+donkey(y)
+\begin_inset Newline newline
+\end_inset
+
+own(x,y)
+\change_unchanged
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279982
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280653
+\begin_inset Formula $\wedge\!\,$
+\end_inset
+
+
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279982
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280702
+z
+\begin_inset space ~
+\end_inset
+
+w
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561279982
+\begin_inset Argument post:3
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561280703
+z = x
+\begin_inset Newline newline
+\end_inset
+
+w = y
+\begin_inset Newline newline
+\end_inset
+
+love(w,z)
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\change_inserted -712698321 1561281199
+The
+\family sans
+Duplex Condition DRS
+\family default
+ can be used to insert duplex conditions:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+
+\change_inserted -712698321 1561281613
+\begin_inset Flex QDRS
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281297
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281237
+x
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281305
+x
+\begin_inset Formula $\in$
+\end_inset
+
+ X
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281209
+\begin_inset Argument post:1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281317
+every
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281209
+\begin_inset Argument post:2
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281320
+x
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281209
+\begin_inset Argument post:3
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281327
+y
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281209
+\begin_inset Argument post:4
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561282714
+secretary(y)
+\begin_inset Newline newline
+\end_inset
+
+hire(x,y)
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Enumerate
+
+\change_inserted -712698321 1561281636
+The
+\family sans
+Negated DRS
+\family default
+ adds a DRS preceded by a negation symbol:
+\end_layout
+
+\begin_deeper
+\begin_layout Standard
+
+\change_inserted -712698321 1561281719
+\begin_inset Flex NegDRS
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281667
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281667
+x
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281697
+donkey(x)
+\begin_inset Newline newline
+\end_inset
+
+green(x)
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+
+\change_inserted -712698321 1561281800
+Finally,
+\family sans
+DRS with Sentence above
+\family default
+ lets you do what it promises: adding a sentence above the box representation:
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1561282183
+\begin_inset VSpace defskip
+\end_inset
+
+
+\begin_inset Flex SDRS
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281911
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281859
+A donkey is green
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281886
+\begin_inset Argument 2
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281888
+x
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561281854
+donkey(x)
+\begin_inset Newline newline
+\end_inset
+
+green(x)
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset VSpace defskip
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1561282246
+The
+\emph on
+drs
+\emph default
+ package provides some means to customize the layout and appearance of the
+ DRS boxes.
+ Please refer to the package manual
+\begin_inset CommandInset citation
+LatexCommand cite
+key "drs"
+literal "false"
+
+\end_inset
+
+ for details.
+\change_unchanged
+
+\end_layout
+
+\begin_layout Section
+Phonetic Symbols (IPA)
+\end_layout
+
+\begin_layout Standard
+You do not need the Linguistics module to insert phonetic symbols, this
+ is a base functionality of \SpecialChar LyX
+.
+ However, since this is frequently used by linguists, we will describe it
+ (briefly) in this manual nevertheless.
+\end_layout
+
+\begin_layout Standard
+If you use traditional \SpecialChar LaTeX
+ or PDF\SpecialChar LaTeX
+, a prerequisite to use \SpecialChar LyX
+'s IPA support is
+ the \SpecialChar LaTeX
+ package
+\emph on
+tipa
+\emph default
+
+\begin_inset CommandInset citation
+LatexCommand cite
+key "tipa"
+literal "true"
+
+\end_inset
+
+, which is automatically loaded by \SpecialChar LyX
+ if you follow the procedure described
+ below.
+ If you use Unicode fonts (i.
+\begin_inset space \thinspace{}
+\end_inset
+
+e., if you have clicked
+\begin_inset Quotes eld
+\end_inset
+
+Use non-\SpecialChar TeX
+ fonts
+\begin_inset Quotes erd
+\end_inset
+
+ in
+\family sans
+Document\SpecialChar menuseparator
+Settings\SpecialChar menuseparator
+Fonts
+\family default
+), the package
+\emph on
+xunicode
+\emph default
+ is loaded instead (since
+\emph on
+tipa
+\emph default
+ does not work in this context).
+
+\begin_inset Foot
+status open
+
+\begin_layout Plain Layout
+See also https://github.com/wspr/fontspec/issues/280 and the discussion in
+ docutils-devel (https://www.mail-archive.com/search?l=mid&q=1487664738.2405.6.camel%
+40lyx.org).
+\end_layout
+
+\end_inset
+
+ The
+\emph on
+xunicode
+\emph default
+ package emulates the
+\emph on
+tipa
+\emph default
+ output, but is not perfect at that, so some things might not look as expected.
+ Furthermore, you need to take care in this case to use a font that includes
+ the IPA glyphs (such as
+\emph on
+CMU Serif
+\emph default
+ or
+\emph on
+SIL Doulos
+\emph default
+).
+ You can also specify an extra font only for IPA by adding the following
+ to
+\family sans
+Document\SpecialChar menuseparator
+Settings\SpecialChar menuseparator
+LaTeX Preamble
+\family default
+:
+\end_layout
+
+\begin_layout Standard
+\begin_inset listings
+lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}"
+inline false
+status open
+
+\begin_layout Plain Layout
+
+
+\backslash
+AtBeginDocument{%
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+newfontfamily{
+\backslash
+ipafont}{CMU Serif}% or another font
+\end_layout
+
+\begin_layout Plain Layout
+
+
+\backslash
+def
+\backslash
+useTIPAfont{
+\backslash
+ipafont}
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\end_inset
+
+Additionally, and independent from which of the above approaches you use,
+ if you want to have instant preview, you should have the
+\emph on
+preview-latex
+\emph default
+ package
+\begin_inset CommandInset citation
+LatexCommand cite
+key "preview"
+literal "true"
+
+\end_inset
+
+ installed.
+\end_layout
+
+\begin_layout Standard
+The recommended way to insert phonetic symbols is via
+\family sans
+Insert\SpecialChar menuseparator
+Special characters\SpecialChar menuseparator
+Phonetic symbols.
+
+\family default
+This gives you an input box (
+\begin_inset Quotes eld
+\end_inset
+
+inset
+\begin_inset Quotes erd
+\end_inset
+
+ in \SpecialChar LyX
+ speak), where you can insert the symbols.
+ Note that this box can be used both for the insertion of small snippets
+ (inline) and multiple paragraphs of phonetic notation.
+ While the cursor is inside the box, a toolbar opens, which provides the
+ basic set of phonetic symbols (sorted by the IPA categories).
+\begin_inset Foot
+status collapsed
+
+\begin_layout Plain Layout
+Currently, there is one symbol missing: the labiodental flap (added to the
IPA in 2005).
This symbol is not yet supported by the
\emph on
\end_inset
.
+\change_inserted -712698321 1561276082
+
+\end_layout
+
+\begin_layout Bibliography
+
+\change_inserted -712698321 1561276305
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "drs"
+literal "false"
+
+\end_inset
+
+ The drs
+\emph on
+
+\emph default
+package:
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561282286
+
+https://ctan.org/tex-archive/macros/latex/contrib/drs
+\end_layout
+
+\end_inset
+
+.
+\change_unchanged
+
\end_layout
\begin_layout Bibliography
\end_inset
.
+\change_inserted -712698321 1561276282
+
+\end_layout
+
+\begin_layout Bibliography
+
+\change_inserted -712698321 1561276302
+\begin_inset CommandInset bibitem
+LatexCommand bibitem
+key "pict2e"
+literal "false"
+
+\end_inset
+
+The pict2e package:
+\begin_inset Flex URL
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1561276288
+
+https://ctan.org/tex-archive/macros/latex/contrib/pict2e
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\change_unchanged
+
\end_layout
\begin_layout Bibliography
return
cov_req = False
- glosses = ("\\begin_inset Flex Interlinear Gloss (2 Lines)", "\\begin_inset Flex Interlinear Gloss (3 Lines)")
+ glosses = ["\\begin_inset Flex Interlinear Gloss (2 Lines)", "\\begin_inset Flex Interlinear Gloss (3 Lines)"]
for glosse in glosses:
i = 0
while True:
i += 1
+def revert_drs(document):
+ " Revert DRS insets (linguistics) to ERT "
+
+ if not "linguistics" in document.get_module_list():
+ return
+
+ cov_req = False
+ drses = ["\\begin_inset Flex DRS", "\\begin_inset Flex DRS*",
+ "\\begin_inset Flex IfThen-DRS", "\\begin_inset Flex Cond-DRS",
+ "\\begin_inset Flex QDRS", "\\begin_inset Flex NegDRS",
+ "\\begin_inset Flex SDRS"]
+ for drs in drses:
+ i = 0
+ while True:
+ i = find_token(document.body, drs, i)
+ if i == -1:
+ break
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of DRS inset")
+ i += 1
+ continue
+
+ # Check for arguments
+ arg = find_token(document.body, "\\begin_inset Argument 1", i, j)
+ endarg = find_end_of_inset(document.body, arg)
+ prearg1content = []
+ if arg != -1:
+ argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find Argument 1 plain Layout")
+ i += 1
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ prearg1content = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3:
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ # re-find inset end
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of DRS inset")
+ i += 1
+ continue
+
+ arg = find_token(document.body, "\\begin_inset Argument 2", i, j)
+ endarg = find_end_of_inset(document.body, arg)
+ prearg2content = []
+ if arg != -1:
+ argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find Argument 2 plain Layout")
+ i += 1
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ prearg2content = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3:
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ # re-find inset end
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of DRS inset")
+ i += 1
+ continue
+
+ arg = find_token(document.body, "\\begin_inset Argument post:1", i, j)
+ endarg = find_end_of_inset(document.body, arg)
+ postarg1content = []
+ if arg != -1:
+ argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find Argument post:1 plain Layout")
+ i += 1
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ postarg1content = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3:
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ # re-find inset end
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of DRS inset")
+ i += 1
+ continue
+
+ arg = find_token(document.body, "\\begin_inset Argument post:2", i, j)
+ endarg = find_end_of_inset(document.body, arg)
+ postarg2content = []
+ if arg != -1:
+ argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find Argument post:2 plain Layout")
+ i += 1
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ postarg2content = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3:
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ # re-find inset end
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of DRS inset")
+ i += 1
+ continue
+
+ arg = find_token(document.body, "\\begin_inset Argument post:3", i, j)
+ endarg = find_end_of_inset(document.body, arg)
+ postarg3content = []
+ if arg != -1:
+ argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find Argument post:3 plain Layout")
+ i += 1
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ postarg3content = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3:
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ # re-find inset end
+ j = find_end_of_inset(document.body, i)
+ if j == -1:
+ document.warning("Malformed LyX document: Can't find end of DRS inset")
+ i += 1
+ continue
+
+ arg = find_token(document.body, "\\begin_inset Argument post:4", i, j)
+ endarg = find_end_of_inset(document.body, arg)
+ postarg4content = []
+ if arg != -1:
+ argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
+ if argbeginPlain == -1:
+ document.warning("Malformed LyX document: Can't find Argument post:4 plain Layout")
+ i += 1
+ continue
+ argendPlain = find_end_of_inset(document.body, argbeginPlain)
+ postarg4content = document.body[argbeginPlain + 1 : argendPlain - 2]
+
+ # remove Arg insets and paragraph, if it only contains this inset
+ if document.body[arg - 1] == "\\begin_layout Plain Layout" and find_end_of_layout(document.body, arg - 1) == endarg + 3:
+ del document.body[arg - 1 : endarg + 4]
+ else:
+ del document.body[arg : endarg + 1]
+
+ # The respective LaTeX command
+ cmd = "\\drs"
+ if drs == "\\begin_inset Flex DRS*":
+ cmd = "\\drs*"
+ elif drs == "\\begin_inset Flex IfThen-DRS":
+ cmd = "\\ifdrs"
+ elif drs == "\\begin_inset Flex Cond-DRS":
+ cmd = "\\condrs"
+ elif drs == "\\begin_inset Flex QDRS":
+ cmd = "\\qdrs"
+ elif drs == "\\begin_inset Flex NegDRS":
+ cmd = "\\negdrs"
+ elif drs == "\\begin_inset Flex SDRS":
+ cmd = "\\sdrs"
+
+ beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
+ endInset = find_end_of_inset(document.body, i)
+ endPlain = find_token_backwards(document.body, "\\end_layout", endInset)
+ precontent = put_cmd_in_ert(cmd)
+ precontent += put_cmd_in_ert("{") + prearg1content + put_cmd_in_ert("}")
+ if drs == "\\begin_inset Flex SDRS":
+ precontent += put_cmd_in_ert("{") + prearg2content + put_cmd_in_ert("}")
+ precontent += put_cmd_in_ert("{")
+
+ postcontent = []
+ if cmd == "\\qdrs" or cmd == "\\condrs" or cmd == "\\ifdrs":
+ postcontent = put_cmd_in_ert("}{") + postarg1content + put_cmd_in_ert("}{") + postarg2content + put_cmd_in_ert("}")
+ if cmd == "\\condrs" or cmd == "\\qdrs":
+ postcontent += put_cmd_in_ert("{") + postarg3content + put_cmd_in_ert("}")
+ if cmd == "\\qdrs":
+ postcontent += put_cmd_in_ert("{") + postarg4content + put_cmd_in_ert("}")
+ else:
+ postcontent = put_cmd_in_ert("}")
+
+ document.body[endPlain:endInset + 1] = postcontent
+ document.body[beginPlain + 1:beginPlain] = precontent
+ del document.body[i : beginPlain + 1]
+ if not cov_req:
+ document.append_local_layout("Provides covington")
+ add_to_preamble(document, ["\\usepackage{drs,covington}"])
+ cov_req = True
+ i = beginPlain + 1
+
+
##
# Conversion hub
#
[574, [convert_ruby_module, convert_utf8_japanese]],
[575, [convert_lineno]],
[576, []],
- [577, [convert_linggloss]]
+ [577, [convert_linggloss]],
+ [578, []]
]
-revert = [[576, [revert_linggloss, revert_subexarg]],
+revert = [[576, [revert_drs]],
+ [576, [revert_linggloss, revert_subexarg]],
[575, [revert_new_languages]],
[574, [revert_lineno]],
[573, [revert_ruby_module, revert_utf8_japanese]],