source: TraumaOntologies/doc/manual.tex@ 5

Last change on this file since 5 was 5, checked in by Bart Vastenhouw, 5 years ago

Intermediate update

File size: 22.0 KB
Line 
1\documentclass[]{article}
2
3% Use utf-8 encoding for foreign characters
4\usepackage[utf8]{inputenc}
5
6% the page geometry.
7\usepackage[a4paper,top=2cm, bottom=2cm, left=1cm, right=1cm]{geometry}
8\usepackage{minibox}
9% Uncomment some of the following if you use the features
10%
11% Running Headers and footers
12%\usepackage{fancyhdr}
13
14% Multipart figures
15%\usepackage{subfigure}
16
17% More symbols
18%\usepackage{amsmath}
19%\usepackage{amssymb}
20%\usepackage{latexsym}
21
22% Surround parts of graphics with box
23\usepackage{boxedminipage}
24
25% Package for including code in the document
26\usepackage{listings}
27
28% If you want to generate a toc for each chapter (use with book)
29\usepackage{minitoc}
30
31% This is now the recommended way for checking for PDFLaTeX:
32\usepackage{ifpdf}
33\usepackage{comment}
34\usepackage{array}
35\usepackage{url}
36\usepackage{listings}
37\usepackage{color}
38\usepackage{amsmath}
39\usepackage{mathtools}
40\usepackage{fancyvrb}
41\usepackage{caption}
42
43% clickable links in the contents section
44\usepackage{hyperref}
45\hypersetup{
46 colorlinks,
47 citecolor=black,
48 filecolor=black,
49 linkcolor=black,
50 urlcolor=black
51}
52% this gives us \FloatBarrier to prevent images to float all to the end
53\usepackage{placeins}
54
55% do not add additional authors in references
56%\usepackage{apacite}
57
58%\bibliographystyle{plainnat}
59\bibliographystyle{acm}
60
61
62\title{Ontologies for dialog management and trauma treatment}
63\author{ W. Pasman, M. Tielman, W.P. Brinkman}
64
65\date{\today}
66
67
68\begin{document}
69
70
71\maketitle
72\abstract{\noindent
73
74This document presents the trauma ontologies software that can interview patients with PTSD to help recall of details of traumatic events. It advances research software that was proven effective. The software uses a hierarchy of concepts, the ontology, to steer the interview. The same ontology files from the original tests can be used with this software. Support has been added to allow other filetypes besides owl. Support for different languages is available, and new languages can be added easily. The original strategy can be used, but alternative strategies used to traverse the concept hierarchy can be created as required. The state of the dialog can be saved and restored at any time. Sample ontologies are provided for a ready-to-use system to handle child sexual abuse and various versions for military post-traumatic stress disorder in various conflict areas. A demo GUI is provided to show the functionality.}
75
76\pagebreak
77\tableofcontents
78
79\pagebreak
80
81\section{Introduction}
82PTSD patients often have fragmented memories of their trauma and are very reluctant to recall them, requiring detailed questions to stimulate memory retrieval. Previously, a system was developed that showed the effectivity of an ontology-based dialog system to help humans to recall their traumatic experiences \cite{TielmanThesis2018}
83These ontologies have been tested and shown effective with real subjects (\cite{Tielman17} , \cite{Tielman15} ).
84
85This document describes the technical details of the traumaontologies module. The code is in Java, and supports the Maven build system for easy incorporation into other maven based code. The main functionality of the module is to generate questions to treat traumas. We start with an overview of the main classes (Figure \ref{classdiagram}).
86
87
88
89
90\begin{center}
91 \includegraphics[width=0.8\textwidth]{figs/classdiagram.pdf}
92 \captionof{figure}{UML diagram of the core code}
93 \label{classdiagram}
94\end{center}
95
96
97The question generation process is completely controlled by the AnswerState object. It contains the state of the question-answer process, including all answers received that led up to this state. It has a function \verb|getOptions| to get the next question, and a function \verb|with| that creates a new AnswerState from the answer to the question as given by the user.
98
99The AnswerState in turn depends on its configuration and on a hierarchy, or tree, of relevant concepts.
100
101Regarding the configuration, there are various instances of AnswerState, such as AnswerDepthFirstState and ListOfAnswersState, that result in different interpretation of the concept tree.
102
103The concept tree defines a hierarchy of all concepts that are relevant for the process. The concepts in the tree contain the exact questions plus allowed answers for each concept. The concept tree is currently read from an OWL file, but this can be adapted to support other formats.
104
105The
106
107\subsection{example}
108First an example to illustrate the mechanism.
109Suppose the tree contains a concept "building" with children "house", "library" and "church", and "house" has children "appartment" and "bungalow". Additionally, we assume that building has properties "size" and "house" has the property "number of inhabitants".
110
111Now suppose that for some treatment, it is useful to ask the user to give details of a relevant building he encountered.
112We start with creating a OntologyAnswerState pointing at building. This will generate questions (and collect answers) to let the user explain what type of building (jost one building) he is thinking about. So the system may ask "can you clarify the type of building? Is it a house, library or church?". If the user answers "house" the system may ask again "can you clarify if it's an appartment or bungalow?".
113
114Next, it may be required to also ask about the properties of the selected house. To do this we replace the OntologyAnswerState with an OntoPropAnswerState pointing at building. The result will be an interview starting as with the OntologyAnswerState, leading to for instance the user's answer that he has a bungalow in mind. But now the questioning proceeds with "what is the size of the bungalow?" and "what are the number of inhabitants?".
115
116Suppose we want to ask about a special house, say the user's own house. We wrap the OntoPropAnswerState in a AnswerStateExplanationDecorator to add some extra explanation that this question is about the user's own house.
117
118Next, we want to ask about both the user's own house and a second, more general house. We can make two AnswerStates, one with and one without the wrappng Decorator. We put them in a ListOfAnswersState, in the correct order for asking. Notice that we can always re-use AnswerState objects because they are immutable.
119
120If there is an unknown number of relevant buildings, we can put the OntoPropAnswerState into a AnswersDepthFirstState. After the user has answered all there is to ask about one house, he will now get the question if there are more relevant houses.
121
122The following sections detail on the AnswerState and concept hierarchy. The example treatment ontologies are discussed. Also the example GUI is discussed.
123
124\section{AnswerState}
125
126AnswerState contains the complete state of the dialog. It defines the how the concept tree will be used. It can provide a question to forward the state and it can create a new state given a user's answer to the question.
127
128So it defines a (possibly partial) answer to a question and the answer type needed to bring it closer to a full answer.
129Specifically, all AnswerStates implement two main functions::
130 \begin{enumerate}
131 \item getOptions() is to be called to get the question and the allowed answers. The state is complete if this returns null.
132 \item with(answer) is called to acquire a new AnswerState that includes the given answer
133 \end{enumerate}
134
135Usually, there will be a loop like this in various places in the code
136\begin{Verbatim}[xleftmargin=.5in]
137while ( TypedQuestion question=state.getOptions() !=null) {
138 present user question.getQuestion()
139 repeat {
140 answer=get user's answer
141 } until question.fits(answer)
142 state=state.with(answer)
143}
144\end{Verbatim}
145
146
147\subsection{Types of AnswerStates}
148Different implementations of AnswerState area avilable, all differing in the way the given concept is used.
149Some of these recursively use other AnswerStates to (recursive) construct a global AnswerState for the entire interview.
150
151\begin{enumerate}
152 \item OntologyAnswerState: This AnswerState visits the children of the initial concept, searching for the best match to what the user has in mind. It offering the user to choose between children nodes repeatedly.
153 The idea is that the initial state is with the most abstract OntologyNode fitting the expectations (typically "object" or "person").
154 In each node, getOptions() returns a set of more accurate ontology
155 nodes that are children of the current node. By calling with(answer)
156 with one of these nodes as argument, the new state is that selected node. If tnat
157 selected node is a leaf node, the state is final and the process is done.
158 Please refer to the javadoc for all details.
159
160 \item PropertiesAnswerState. This AnswerState asks all TypedQuestions (and collects the answers) attributed to the given concept node and all its ancester nodes.
161
162 \item OntoPropAnswerState. This AnswerState first executes the OntologyAnswerState until the user has found the best matching concept. Then it proceeds with the PropertiesAnswerState for that concept. So it collects all relevant info for a given root concept.
163
164 \item AnswersBreathFirstState. This AnswerState takes a concept and the name of the main property (eg, "Name" which refers to a person's name). The main property must be one of the properties of the given concept. It first loops asking the user if there are more of these items and asks the value for the most relevant property (so, it collect eg a list of person names). Then in a second loop, it executes a OntoPropAnswerState procedure to fill in all the details.
165
166 \item AnswersDepthFirstState. This AnswerState takes a start concept (eg "Object" which refers to a physical object that was somehow relevant) It first runs an OntoPropAnswerState procedure on the given concept.. Then it asks if there are more relevant items of this type. If so,it repeats. The result is a list of answers, each detailing on another instance of the concept.
167\end{enumerate}
168
169\subsubsection{OntoPropAnswerState substitutions}\label{ch:substitutions}
170OntoPropAnswerState has a special step when handling getOptions. As mentioned above the state first executes the OntologyAnswerState procedure. The answers from the user are collected in a map with as key the name of the concept and as value
171Suppose thet the
172If the user gave an answer "John" to some property, say "Name", then all subsequent \verb|getOption| calls will substitute any occurences of the property name within square brackets, so "[Name]", replace with the exact answer given by the user. So the question "where did you meet [Name]" would be turned into "where did you meet John".
173
174\subsubsection{AnswersBreathFirstState substitutions}
175The AnswersbreathFirstState uses the above mentioned special step substituting a property in the questions. It makes a list of OntoPropAnswerStates, one for each concept (typically, Person) deemed relevant by the user. But instead of going through the full OntoPropAnswerState, only the main property (eg "Name") is filled in in the OntoPropAnswerState.
176After the user has filled in all main properties (Name), the OntoPropAnswerState will automatically fill in the right names in all remaining questions required to complete the collected OntoPropAnswerStates.
177
178To give an example of how this works, suppose we have a hierarchy of concepts Person with children "father", "mother", "sister" and "brother". All Persons have a property Name and a property Age. An AnswersBreathFirstState procedure would ask repeatedly "Please enter the name of the next relevant person" till all names are collected. Suppose the user mentions "Sue, Peter, Mary, Bob". Then, it would take the first person, and first ask questions like "is Person Sue your father, mother, sister or brother?". After clarifying the exact concept type, the remaining property would be filled in, with a question like "What is [Name]s age" and [Name] can be substituted with Sue because Name is the main property and the answer on the main property question was "Sue". Next, the same procedure is repeated with the remaining names.
179
180\subsection{Loading/Saving}
181The AnswerState can be (de)serialized with Jackson to/from a json formatted object using \verb|objectmapper.writeValueAsString| and \verb|objectmapper.readValue|. Example code is available in PropertiesAnswerStateTest.
182
183
184\subsection{TypedQuestion}
185TypedQuestion objects contain a question for a human (a text string) and a method \verb|fits| that checks if an answer given by the user matches the expected answers. For example if the question is asking a yes/no question, the \verb|fits| function can check if the answer is yes or no.
186
187This is the complete list of TypedQuestion objects::
188\begin{enumerate}
189 \item \verb|Bool|. This is a yes-no question
190 \item \verb|Int|. This is a question that expects an integer number as answer
191 \item \verb|Text|. This question expects any free text as an answer.
192 \item \verb|Word|. This question expects a single word (no whitespace) as answer
193 \item \verb|SelectFromList|. This expects one from a known list of phrases as answer.
194\end{enumerate}
195
196TypedQuestions are generated in two ways:
197\begin{itemize}
198 \item indirectly by code in AnswerState, e.g. to probe the user which concepts from the concept tree that he is thinking about.
199 \item directly from the Property objects in the concept tree that contain specific questions to be asked
200\end{itemize}
201
202
203The TypedQuestion has a function isTranslated(). If this function returns true, answers to this type of question have to be translated. This typically is true for \verb|Bool| and \verb|SelectFromList| questions, but not for \verb|Text| or \verb|Int|,
204
205
206\section{Concept Tree}
207The concept tree is a tree with each node being a concept that is relevant for the interview. It is a tree with concepts ordered from general to more specific, allowing the interview to start at a high-level concept, with more specific concepts as children. The introduction already mentioned 'building' as a possible general concept with a bungalow as a child instance.
208
209In the code, the nodes are of the concept tree are represented by OntologyNode, which extends a standard AttributeTree. The node has a name (String) and a list of Attributes.
210
211The name strings are used directly to be shown to the user, so it is important to use human-understandable names here.
212
213The Attributes are Property objects that contain a TypedQuestion. These questions are usually open-ended questions, as the system does not interpret answers to questions like "what was the size of the house" other than some general type checking capabilities (eg, if the answer must be an integer number, or yes/no).
214
215\subsection{OWL storage format}
216The collection of attribute trees can be stored in many ways, but this implementation provides an implementation using the OWL format.
217Other formats can be easily supported as the OWL format is just an instance of the more general interface used by the AnswerStates.
218The choice for OWL allows the original OWL files from the clinically tested prototype can be used, and the use of the Protege tool for developing the tree.
219
220The OwlTree class converts the database into a Tree, the OwlOntologyNode adapts OwlClass objects to TreeNodes, and the OwlProperty implements the Property interface.
221
222\subsection{Class}
223The \verb|owl:Class| object is used to represent the OntologyNode objects which are the concepts relevant for the interview. A class object in OWL contains an attribute \verb|rdf:ID| and this attribute is used as the name string of the OntologyNode.
224
225\subsection{subClassOf}
226The \verb|rdfs:subClassOf| property is used to define the hierarchy of the classes. It is used to define the parent-children relations between the OntologyNodes.
227
228\subsection{Property}
229The \verb|owl:DatatypeProperty| and \verb|owl:FunctionalProperty| are used to attach properties to a Class.
230These have a number of attributes that are used in specific ways to create a TypedQuestion objects.
231\begin{enumerate}
232 \item \verb|rdfs:label| this attribute contains a full question to be asked to the user during the interview, to elicit the answer
233 \item \verb|rdfs:comment| behaves the same as \verb|rdfs:label|. Only one of these is allowed.
234 \item \verb|rdf:ID| this id can be shown to the user as question, if more specific question text is missing
235 \item \verb|rdfs:domain| the class name (concept) that this property applies to
236 \item \verb|rdfs:range| the range of answers that is allowed as an answer.
237 Can be \verb|http://www.w3.org/2001/XMLSchema#boolean| (creating a \verb|Bool|), \verb|http://www.w3.org/2001/XMLSchema#int|
238 (creating a \verb|Int|), \verb|http://www.w3.org/2001/XMLSchema#string| (creating a \verb|Text|).
239\end{enumerate}
240
241
242\subsection{Included concept trees}\label{ch:concepttrees}
243The code includes several concept hierarchies that have been used in clinical treatment for a number of PTSDs. The concept hierarchies are contained in the following files and ment for specific PTSD treatments:
244\begin{itemize}
245 \item \verb|Child Sexual Abuse.owl|. This is for treating PTSD due to sexual abuse during childhood.
246 \item \verb|War.owl| This is for treating PTSD due to general war situations.
247 \item \verb|War Afghanistan.owl| Treating PTSD due to the Afghanistan war.
248 \item \verb|War Bosnia.owl| Treating PTSD due to the Libyan war.
249 \item \verb|War Libya.owl| Treating PTSD due to the Libyan war.
250\end{itemize}
251
252The example trees have a number of specific concepts that should be handled in the given order
253 \begin{enumerate}
254 \item \verb|Geografische_locatie|. This concept contains general geographical location information about the event.
255 \item \verb|Type_Locatie|. This concept contains more details about the type and details of the geographical location
256 \item \verb|Object|. This concept contains all details about all relevant objects. These should be handled depth-first, asking all information about an object before asking about the next.
257 \item \verb|Persoon|. This concept contains all details about all relevant persons. This should be handled breath-first: first asking all the names of the relevant persons and then asking more about each person in a second run through all persons.
258 \end{enumerate}
259
260Therefore the included treatments should be used in combination with the following AnswerState:
261
262 \begin{Verbatim}[xleftmargin=.5in]
263private void initAnswerState() throws OWLOntologyCreationException {
264 OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
265 OWLOntology ontology = manager.loadOntologyFromOntologyDocument(
266 getClass().getResourceAsStream("/" + treatmentCombo.getSelectedItem()));
267 OwlTreeReasoner reas = new OwlTreeReasoner(ontology);
268 tree = new OwlTree(reas);
269
270 AnswerState geoanswer = new PropertiesAnswerState("Geografische_locatie");
271 AnswerState loctypeanswer = new AnswerStateExplanationDecorator(
272 new OntoPropAnswerState(
273 new OwlOntologyNode("Type_Locatie", reas), null),"In wat voor soort locatie was U?");
274 AnswerState objectsanswer = new AnswerStateExplanationDecorator(
275 new AnswersDepthFirstState("Object","Zijn er nog meer relevante objecten?", tree),
276 "We verzamelen de relevante objecten op de locatie. We gaan een voor een door alle relevante objecten, beginnend bij het eerste object.");
277 AnswerState personsanswer = new AnswerStateExplanationDecorator(
278 new AnswersBreathFirstState(
279 new OwlOntologyNode("Persoon", reas), "Naam", "Zijn er nog meer relevante personen?"),
280 "We verzamelen de relevante personen op de locatie. We verzamelen eerst de namen.");
281
282 dialogState = new ListOfAnswersState(Arrays.asList(geoanswer,
283 loctypeanswer, objectsanswer, personsanswer));
284}
285
286\end{Verbatim}
287
288\section{Interactive example dialog}
289
290Figure \ref{fig:gui} shows the example GUI. The example gui uses the treatments that were developed to treat child sexual abuse and war traumas. When the GUI is started up (e.g., double click the \verb|traumaontologies.with-depdencies.jar| file ) the user is first
291prompted to select one of the included treatments. Then, the user gets presented questions. He can type the answer as text in the field above the answer button. When the answer is completed he clicks 'answer'.
292
293The combobox "EN", "NL" allows the user to select a language of his choice. Currently english and dutch are supported but this can easily be extended by creating additional translation CSV files as described in the section \ref{ch:translation}..
294
295The "Save" shows what would be saved in a pop-up window. The example does not really save data for security reasons.
296
297\begin{center}
298 \includegraphics[width=0.6\textwidth]{figs/gui.png}
299 \label{fig:gui}
300 \captionof{figure}{Example GUI}
301\end{center}
302
303
304\subsection{Connecting with your own GUI}
305The provided example GUI is completely optional: The GUI is just a simple wrapper of the core traumaontologies module to help the user interact with the code in a simple demo mode. The GUI demo also shows how translation functionality can be easily added on top of this.
306
307Also, the provided treatments are optional. You can use your own files containing a concept hierarchy to drive your own therapy in a similar way.
308
309if you want to use the provided treatments (the \verb|owl| files) you should use the initial answer state as was discussed in section \ref{ch:concepttrees}.
310
311
312
313
314\section{Translation}\label{ch:translation}
315The example code in the traumaontologies module returns sentences in Dutch. This is just a choice, ontologies can just as well be written directly in another language. Only some sentences in the system are hard coded, to change this one would have to download and modify the source code.
316
317We recommend to use the translator module (https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/wiki/Translator) as
318used in our example code. The example code shows how to use our translator module to translate the Dutch sentences into English.
319
320Note that the translation files may contain variables of the form [Naam] which may look similar to the variables used in the AnswerStates (section \ref{ch:substitutions}). These should not interfere. All variables in the question sentences should have been replaced by the time they reach the Translation package. The translation package figures out variable substitutions by itself, assuming it receives plain text without any explicit variables.
321
322
323\bibliography{references}{}
324
325
326
327
328
329\end{document}
Note: See TracBrowser for help on using the repository browser.