Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.9
RUN echo export PATH=$HOME/.local/bin:$PATH >> ~/.bashrc
COPY requirements.txt requirements.txt
RUN apt-get update
RUN apt-get install -y make
RUN apt-get install -y texlive-latex-extra
RUN git clone --recursive https://github.com/andreasvc/disco-dop.git
RUN cd disco-dop
RUN pip install --user --no-cache-dir -r requirements.txt
WORKDIR /disco-dop/
RUN pip install sphinx
RUN mkdir -p _static
RUN make install
RUN pip install grapheme
WORKDIR ~/activedopmeru/
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_ENV=development
COPY . .
EXPOSE 5000
RUN python -m flask initdb
RUN python -m flask initpriorities
CMD ["python", "-m", "flask", "run", "--with-threads"]
Binary file added annotate.db
Binary file not shown.
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ def accept():
actions = session['actions']
actions[TIME] = int(round(time() - actions[TIME]))
treestr = None
#tags = {}
if 'dec' in request.args:
actions[DECTREE] += int(request.args.get('dec', 0))
if 'tree' in request.args:
Expand Down Expand Up @@ -1293,8 +1294,7 @@ def download_pdf():

subprocess.run(['pdflatex', '-output-directory', output_dir, os.path.join(output_dir, "file.tex")])

pdf_path = os.path.join(output_dir, "file.pdf")

pdf_path = os.path.join(output_dir, "file.pdf")
return send_file(pdf_path, as_attachment=True, attachment_filename='downloaded_file.pdf')

@app.route('/annotate/exportcgeltree')
Expand Down Expand Up @@ -1654,4 +1654,4 @@ def strip_cgel_metadata(orig_senttok):
treestr = "(ROOT " + cgel_tree.ptb() + ")"
treestr = writediscbrackettree(DrawTree(treestr).nodes[0],new_senttok)
orig_senttok = new_senttok
return(treestr, orig_senttok, tags, orig_tree)
return(treestr, orig_senttok, tags, orig_tree)
56 changes: 56 additions & 0 deletions newsentsExample.csv.rankings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[
[
3,
3.6736298275241372,
"The girl ate pizza with tomatoes",
"id4"
],
[
1,
2.702709644336757,
"The girl ate the pizza with a fork",
"id2"
],
[
2,
2.5013714625137196,
"The girl ate the pizza with the tomatoes",
"id3"
],
[
0,
1.6475508327726855,
"The boy saw the girl under the tree with the telescope in the forest",
"id1"
],
[
7,
0.8895849807473573,
"The mouse saw the little cat",
"id8"
],
[
4,
-0.0,
"The cat saw the pizza",
"id5"
],
[
5,
-0.0,
"The mouse stole the pizza",
"id6"
],
[
6,
-0.0,
"The cat ate the mouse",
"id7"
],
[
8,
-0.0,
"The cat ate the dog",
"id9"
]
]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ numpy
scikit-learn
pylatexenc
Werkzeug==2.2.2
Cython==0.29.37
2 changes: 1 addition & 1 deletion settings.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SECRET_KEY=b';boc.xbanuh;qdaoeiq'
DEBUG = False
GRAMMAR = 'cgelbank2/'
SENTENCES = 'ewt-manual.cgelpos'
SENTENCES = 'newsentsExample.csv'
LIMIT = 70
ANNOTATIONHELP = None
ACCOUNTS = {
Expand Down
55 changes: 28 additions & 27 deletions templates/annotate.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,48 @@
<button id= "reTokenizeButton" onclick="reTokenize()" style="display:none">Re-tokenize</button>
</div>
</form>

{%block script %}
<script>
function makeEditable() {
function makeEditable(){
event.preventDefault();
document.getElementById('editableSent').style.display = "none";
document.getElementById('editInput').style.display = "inline";
document.getElementById('cancelButton').style.display = "inline";
document.getElementById('reTokenizeButton').style.display = "inline";
$("#editableSent").hide();
$("#editInput").css("display", "inline");
$("#cancelButton").css("display", "inline");
$("#reTokenizeButton").css("display", "inline");
}

function cancelEdit() {
function cancelEdit(){
event.preventDefault();
document.getElementById('editableSent').style.display = "inline";
document.getElementById('editInput').style.display = "none";
document.getElementById('cancelButton').style.display = "none";
document.getElementById('reTokenizeButton').style.display = "none";
$("#editableSent").css("display", "inline");
$("#editInput").hide();
$("#cancelButton").hide();
$("#reTokenizeButton").hide();
}
function reTokenize(sentno) {
var newtext = document.getElementById('editInput').value;
var sentno = document.getElementById('sentno').value;
document.getElementById('editableSent').innerText = newtext;
document.getElementById('editableSent').style.display = "inline";
document.getElementById('editInput').style.display = "none";
document.getElementById('cancelButton').style.display = "none";
document.getElementById('reTokenizeButton').style.display = "none";
fetch('/retokenize', {

function reTokenize(){
var newtext = $("#editInput").val();
var sentno = $("#sentno").val();
$("#editableSent").text(newtext)
$("#editableSent").css("display", "inline");
$("#editInput").hide();
$("#cancelButton").hide();
$("#reTokenizeButton").hide();
$.ajax({
method: 'POST',
url: '/retokenize',
headers: {
'Content-Type': 'application/json',
"Content-Type":'application/json'
},
body: JSON.stringify({newtext: newtext, sentno: sentno}),
data: JSON.stringify({newtext: newtext, sentno: sentno})
}).then(data => {
console.log('Success', data);
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch((error) => {
console.error('Error:', error);
});
}
}
</script>

{% endblock %}
<div style="display: none; " id=constraintdiv>
Required: [<span id=showrequire></span>]; Blocked: [<span id=showblock></span>]
</div>
Expand Down
31 changes: 19 additions & 12 deletions templates/edittree.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,41 @@
</div>
{{ msg }}

{%block script %}
<script>
/*goback() is called by the Go back button, which is passed into this page
from the above jinja {{ msg }} tag */
function goback() {
var sentno = document.getElementById('sentno').value;
var sentno = $('#sentno').val();
window.location.href = '/annotate/annotate/' + sentno;
}
/* undoAccept() undos accept*/
function undoAccept() {
var sentid = document.getElementById('sentid').value;
var sentno = document.getElementById('sentno').value;
fetch('/undoaccept', {
var sentid = $('#sentid').val();
var sentno = $('#sentno').val();
$.ajax({
method: 'POST',
url: '/undoaccept',
headers: {
'Content-Type': 'application/json',
"Content-Type":'application/json'
},
body: JSON.stringify({sentid: sentid}),
data: JSON.stringify({sentid: sentid})
}).then(data => {
console.log('Success', data);
$(location).attr('href') = '/annotate/annotate/' + sentno;
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
window.location.href = '/annotate/annotate/' + sentno;
}
)
.then(redirect('/annotate/annotate/1'))
.catch((error) => {
console.error('Error:', error);
});

}
</script>



{% endblock %}

<div id=help style="display: none;">
<ul>
<li>To change a label, click on a node to select a different label from a list.
Expand Down
2 changes: 2 additions & 0 deletions templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!doctype html>
<title>Treebank Annotation</title>
<script src="/annotate/static/script.js"></script>
<!-- Add jQuery-->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<link rel=stylesheet type=text/css href="/annotate/static/style.css">
{%- for message in get_flashed_messages() %}
<div class=flash>{{ message }}</div>
Expand Down