[go: up one dir, main page]

Menu

[r9]: / mvc / correction.jsp  Maximize  Restore  History

Download this file

157 lines (142 with data), 5.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<%
//
// Copyright 2011 New Zealand Institute of Language, Brain and Behaviour,
// University of Canterbury
// Written by Robert Fromont - robert.fromont@canterbury.ac.nz
//
// This file is part of LaBB-CAT.
//
// LaBB-CAT 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 2 of the License, or
// (at your option) any later version.
//
// LaBB-CAT 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 LaBB-CAT; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
%><%@ page import = "java.io.*"
%><%@ page import = "java.net.*"
%><%@ page import = "java.util.*"
%><%@ page import = "nz.ac.canterbury.ling.ag.*"
%><%@ page import = "java.sql.*"
%><%
{
request.setAttribute("title", "regenerate layers");
Connection connection = (Connection)request.getAttribute("db");
ServletContext context = request.getSession().getServletContext();
Vector<String> vMessages = (Vector<String>)request.getAttribute("messages");
Vector<String> vErrors = (Vector<String>)request.getAttribute("errors");
String sAnnotationUid = ""+request.getParameter("annotation_uid");
MetaAnnotation line = new MetaAnnotation(sAnnotationUid);
String sSMTPHost = context.getInitParameter("SMTPHost");
String sCorrectionsEmail = context.getInitParameter("correctionsEmail");
String sTitle = context.getInitParameter("title");
String sTranscriptUrl = context.getInitParameter("transcriptUrl");
String sHtmlTranscriptUrl = context.getInitParameter("htmlTranscriptUrl");
String sTranscriptPath = context.getInitParameter("transcriptPath");
String sTranscriptSubdir = context.getInitParameter("transcriptSubdir");
String sCorpusName = "";
String sFamilyName = "";
boolean bForm = true;
try
{
// from the uid info, get the transcription word and AG id
line = new DbMetaAnnotation(line, connection);
// from AG id get transcript name
DbAnnotationGraph ag = new DbAnnotationGraph(
line.getGraphId(), connection);
ag.loadRow();
line.setGraph(ag);
// get start/end times
line.setStartAnchor(new DbAnchor(
ag, line.getStartAnchor().getId(), connection));
line.setEndAnchor(new DbAnchor(
ag, line.getEndAnchor().getId(), connection));
// get speaker info
DbGraphSpeaker speaker = new DbGraphSpeaker(
new GraphSpeaker(ag, Integer.parseInt(line.getLabel())), connection);
request.setAttribute("ag", ag);
request.setAttribute("line", line);
request.setAttribute("speaker", speaker);
GraphFragment fragment = new DbGraphFragment(line, connection);
// handle form
String sCommand = request.getParameter("command");
if (sCommand != null)
{
String sCorrection = request.getParameter("correction");
if (sCorrection.trim().equals(fragment.getFragmentText().trim()))
{
request.setAttribute("message", "Your suggestion is the same as the original text. Please enter your correction");
}
else
{
bForm = false;
String sMessage = "A correction has been suggested for "
+ ag.getName();
if (request.getRemoteUser() != null)
{
sMessage += "\nSuggested by: " + request.getRemoteUser();
}
sMessage += "\nTranscript: " + sHtmlTranscriptUrl
+ "?format=htmlapplet&ag_id=" + ag.getId()
+ "#" + line.getStartAnchor().getOffsetId();
String sTrsTranscriptUrl = sHtmlTranscriptUrl.replaceFirst("transcript\\.jsp", "")
+ sTranscriptUrl
+ "/" + ag.getCorpusName()
+ "/" + ag.getSeriesName()
+ "/" + sTranscriptSubdir
+ "/" + ag.getName();
sMessage += "\nUtterence time: "
+ line.getStartAnchor().getOffset();
sMessage += "\nTranscript file: " + sTrsTranscriptUrl;
sMessage += "\n\nCurrent text: ";
sMessage += "\n----------------------------------------\n";
sMessage += fragment.getFragmentText();
sMessage += "\n----------------------------------------";
sMessage += "\n\nSuggested correction: ";
sMessage += "\n----------------------------------------\n";
sMessage += sCorrection;
sMessage += "\n----------------------------------------";
try
{
nz.net.fromont.mail.Mailer mailer
= new nz.net.fromont.mail.Mailer(
sSMTPHost, sCorrectionsEmail);
mailer.sendMessage(
sCorrectionsEmail,
"[" + sTitle + "] Suggested correction: " + ag.getName(),
sMessage);
request.setAttribute(
"result", "Thank you, your suggestion has been submitted");
}
catch (Exception ex)
{
request.setAttribute(
"result", "Your request was not submitted: <br>"
+ ex + "<br>"
+ "Please email <a href='mailto:" + sCorrectionsEmail + "'>"
+ sCorrectionsEmail + "</a>" );
}
} // suggestion is different from original text
} // handle form
if (bForm)
{
request.setAttribute("form", new Boolean(true));
request.setAttribute("fragment", fragment);
}
}
catch (Exception x)
{
request.setAttribute(
"message", "Specified utterance could not be found"
+ " ("+x+")");
}
request.setAttribute("mvcViewPath", "/mvc/correction_html.jsp");
}
%>