David Arnold has asked for the wisdom of the Perl Monks concerning the following question:
All,
I have a files of exercises written in latex that I'd like to parse. I am new to this so be kind.
The exercise occurs between
pairs. Inside this pair are pairs:\begin{exer} \end{exer}
\begin{exertext}...\end{exertext} delimiting the problem statement.
\begin{soln}...\end{soln} delimiting the problem solution
\begin{answer}...\end{answer} delimiting a backanswer that goes in the back of the textbook.
Finally, there are sporadic directions that are included betwen \begin{instructions}...\end{instructions} pairs. A short example:
\begin{instructions} In Exercises~\ref{2.nformst} and~\ref{2.nformend +} , given the function $\phi$, place the ordinary differential equation $\phi(t,y,y')=0$ in normal form. \end{instructions} \begin{exer} \begin{exertext} \label{2.nformst} $\phi(x,y,z)=x^2z+(1+x)y$ \end{exertext} \begin{soln} $\phi(t,y,y') = t^2y'+(1+t)y = 0$ must be solved for $y'$. We get $$y'= -\frac{(1+t)y}{t^2}.$$ \end{soln} \begin{answer}$y'= -\dfrac{(1+t)y}{t^2}.$\end{answer} \end{exer} \begin{exer} \begin{exertext} \label{2.nformend} $\phi(x,y,z)=xz-2y-x^2$ \end{exertext} \begin{soln} $\phi(t,y,y')=ty'-2y-t^2$ must be solved for $y'$. We get $$y'=\frac{2y+t^2}{t}.$$ \end{soln} \end{exer} \begin{instructions} In Exercises~\ref{2.1st}--\ref{exer2.1.6}, show that the given solution is a general solution of the differential equation. Use a computer or calculator to sketch the solutions for the given values of the arbitrary constant. Experiment with different intervals for $t$ until +you have a plot that shows what you consider to be the most important behavior of the family. \end{instructions} \begin{exer} \begin{exertext} \label{2.1st} $y'=-ty$, $y(t)=Ce^{-(1/2)\,t^2}$, $C=-3,-2,\ldots,3$ \end{exertext} \begin{soln} $y(t)' = -Cte^{-(1/2)\,t^2}$ and $-ty(t) = -tCe^{-(1/2)\,t^2}$, so $y'=-ty$. \par \exfig{ex2.1ans01} \end{soln} \begin{answer}\exfig{ex2.1ans01}\end{answer} \end{exer}
Is there a module on CPAN which I can use to parse this document. My goal is to put all the exercise problem statements (delimited by \begin{exertext}...\end{exertext}) in a file, all the solutions in a second file, all the backanswers in a third file, etc.
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing Exercise set
by jZed (Prior) on Apr 13, 2005 at 21:42 UTC | |
|
Re: Parsing Exercise set
by jimbojones (Friar) on Apr 13, 2005 at 22:25 UTC | |
|
Re: Parsing Exercise set
by davidrw (Prior) on Apr 13, 2005 at 22:12 UTC | |
|
Re: Parsing Exercise set
by chas (Priest) on Apr 13, 2005 at 21:36 UTC |