%% LaTeX Beamer presentation template (requires beamer package)
%% see http://latex-beamer.sourceforge.net/
%% idea contributed by H. Turgut Uyar
%% template based on a template by Till Tantau
%% this template is still evolving - it might differ in future releases!


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%  Uncomment version below for creating normal slides  %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[c]{beamer}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\mode<presentation>

% Set up an \omitfromhandout command to specify slides that should be omitted
% when generating the handout.
\makeatletter
\newwrite\tf@ofh
\immediate\openout\tf@ofh\jobname.ofh
\makeatother

\newcommand{\omitfromhandout}{\addtocontents{ofh}{\thepage}}

\renewcommand<>{\omitfromhandout}[0]{{\only#1{\beameroriginal{\omitfromhandout}}}}

%\ Make sure the GATE theme is used
\usetheme{GATE}
\input{slides-preamble}
\setbeamerfont{alerted text}{series=\bfseries}

\title{Creating new Resource Types}
\subtitle{Additional topics}

% - Use the \inst{?} command only if the authors have different
%   affiliation.
%\author{F.~Author\inst{1} \and S.~Another\inst{2}}
%\author{\inst{1}}

% - Use the \inst command only if there are several affiliations.
% - Keep it simple, no one is interested in your street address.
%\institute{University of Sheffield}

% This is only inserted into the PDF information catalog. Can be left
% out.
\subject{Creating new Resource Types}

% If you have a file called "university-logo-filename.xxx", where xxx
% is a graphic format that can be processed by latex or pdflatex,
% resp., then you can add a logo as follows:

%\pgfdeclareimage[height=2cm]{university-logo}{../../images/logo.png}
%\logo{\pgfuseimage{university-logo}}



% Delete this, if you do not want the table of contents to pop up at
% the beginning of each subsection:
\AtBeginSubsection[]
{
\begin{frame}<beamer>
\frametitle{Outline}
\tableofcontents[currentsection, currentsubsection]
\end{frame}
}

% If you wish to uncover everything in a step-wise fashion, uncomment
% the following command:

%\beamerdefaultoverlayspecification{<+->}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}[fragile]{Corpus-level processing}
\begin{itemize}
\item When running a PR over a corpus of more than one document, you may want
  to do some additional pre- and post-processing before the first and after the
  last document.
\item To do this, implement \lstinline!gate.creole.ControllerAwarePR!
\item Three callback methods called at key points in the execution of the {\em
  controller that contains the PR}:
  \begin{itemize}
  \item \lstinline!controllerExecutionStarted!
  \item \lstinline!controllerExecutionFinished!
  \item \lstinline!controllerExecutionAborted!
  \end{itemize}
\item Parameter is the \lstinline!Controller!.
\item ``aborted'' callback also receives the Throwable that caused the abort.
\end{itemize}
\end{frame}

\begin{frame}[fragile]{Corpus-level processing}
\begin{itemize}
\item So if the controller is a \lstinline!CorpusController!, these correspond
  to:
  \begin{itemize}
  \item before the first document
  \item after the last document
  \item when something goes wrong
  \end{itemize}
\end{itemize}
\end{frame}

\begin{frame}[fragile]{ControllerAwarePR example}
\begin{lstlisting}[texcl]
public class ExampleAnalyser
     extends AbstractLanguageAnalyser
     implements ControllerAwarePR {
  public void controllerExecutionStarted(Controller c) {
    if(c instanceof CorpusController) {
      System.out.println("Processing corpus " +
          ((CorpusController)c).getCorpus().getName());
    }
    else {
      System.out.println(
          "Running in a simple pipeline");
    }
  }

  // controllerExecutionFinished is similar
}
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]{\color{gate-dark-green} Exercise 1: Corpus statistics}
Add corpus statistics to your DocStats PR:
\begin{itemize}
\item Add private fields to keep a running total count of words (and
  nouns/verbs).
\item Implement \lstinline!ControllerAwarePR!.
\item In the ``started'' callback, initialize these totals to 0.
\item In the ``finished'' callback
  \begin{itemize}
  \item check whether you are running in \lstinline!CorpusController!
  \item if so, put the total counts into features on the controller's
    \lstinline!Corpus!.
  \end{itemize}
\item You can leave the ``aborted'' callback empty (or just print a message).
\end{itemize}
Example solution on the wiki.
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}[fragile]{Adding actions to the GUI}
\begin{itemize}
\item Any (language, processing or visual) resource can contribute
  \emph{actions} to the GATE developer GUI.
\item These appear as items on the resource's right-click menu.  For example:
  \begin{itemize}
  \item The ``Run'' option for controllers comes from the controller editor VR
  \item The ``Save as\ldots'' and ``Delete ontology data'' options for an
    ontology LR come from the LR itself.
  \end{itemize}
\item This is done by implementing the interface
  \lstinline!gate.gui.ActionsPublisher!
\item One method, returning a \lstinline!List! of
  \lstinline!javax.swing.Action! objects.
\end{itemize}
\end{frame}

\begin{frame}[fragile]{\color{gate-dark-green} Exercise 2: ActionsPublisher}
Implement cumulative statistics for your DocStats PR:
\begin{itemize}
\item keep a running total as before, but rather than resetting it in
  \lstinline!controllerExecutionStarted!, provide an action to reset it
  explicitly.
\item provide another action to display the current total.
\item example code available on the wiki.
\end{itemize}
\end{frame}

\end{document}
% vim:ft=tex:
