Skip to content

Commit

Permalink
Merge pull request #40 from etern/master
Browse files Browse the repository at this point in the history
move to Python3, add colorful annotation.
  • Loading branch information
jiesutd authored Apr 20, 2022
2 parents 8419caf + 51ea1b6 commit 5fd888d
Show file tree
Hide file tree
Showing 8 changed files with 1,171 additions and 1,401 deletions.
504 changes: 237 additions & 267 deletions Event_beta.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For more details, please refer to [our paper (ACL2018:demo, best demo nomination

This GUI annotation tool is developed with tkinter package in Python.

System required: Python 2.7
System required: Python 3.6

Author: [Jie Yang](https://jiesutd.github.io), Assistant Professor at Zhejiang University, China.

Expand Down
1,326 changes: 600 additions & 726 deletions YEDDA.py

Large diffs are not rendered by default.

99 changes: 36 additions & 63 deletions YEDDA_Admin.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
# -*- coding: utf-8 -*-
# @Author: Jie Yang from SUTD
# @Date: 2016-Jan-06 17:11:59
# @Last Modified by: Jie Yang, Contact: jieynlp@gmail.com
# @Last Modified time: 2017-09-24 21:47:14
#!/usr/bin/env python
# coding=utf-8

from Tkinter import *
from ttk import *#Frame, Button, Label, Style, Scrollbar
import tkFileDialog
import tkFont
import re
from collections import deque
import pickle
import os.path
import platform
from utils.recommend import *
from utils.metric4ann import *
import tkinter.filedialog as tkFileDialog
import tkinter.messagebox as tkMessageBox
from tkinter import *
from tkinter.ttk import * # Frame, Button, Label, Style, Scrollbar

from utils.compareAnn import *
import tkMessageBox
from utils.metric4ann import *


class Example(Frame):
Expand All @@ -29,41 +17,35 @@ def __init__(self, parent):
self.parent = parent
self.fileName = ""
# default GUI display parameter

self.textColumn = 3

self.initUI()



def initUI(self):

self.parent.title(self.Version)
self.pack(fill=BOTH, expand=True)
for idx in range(0,self.textColumn):

for idx in range(0, self.textColumn):
if idx == 1:
self.columnconfigure(idx, weight =10)
self.columnconfigure(idx, weight=10)
else:
self.columnconfigure(idx, weight =1)
self.columnconfigure(idx, weight=1)
# for idx in range(0,2):
# self.rowconfigure(idx, weight =1)
the_font=('TkDefaultFont', 18, )
the_font = ('TkDefaultFont', 18,)
style0 = Style()
style0.configure(".", font=the_font, )

width_size = 30

abtn = Button(self, text="Multi-Annotator Analysis", command=self.multiFiles, width = width_size)
abtn = Button(self, text="Multi-Annotator Analysis", command=self.multiFiles, width=width_size)
abtn.grid(row=0, column=1)

recButton = Button(self, text="Pairwise Comparison", command=self.compareTwoFiles, width = width_size)
recButton = Button(self, text="Pairwise Comparison", command=self.compareTwoFiles, width=width_size)
recButton.grid(row=1, column=1)


cbtn = Button(self, text="Quit", command=self.quit, width = width_size)
cbtn = Button(self, text="Quit", command=self.quit, width=width_size)
cbtn.grid(row=2, column=1)


def ChildWindow(self, input_list, result_matrix):
file_list = []
for dir_name in input_list:
Expand All @@ -74,8 +56,7 @@ def ChildWindow(self, input_list, result_matrix):
else:
file_list.append(dir_name)


#Create menu
# Create menu
self.popup = Menu(self.parent, tearoff=0)
self.popup.add_command(label="Next", command=self.selection)
self.popup.add_separator()
Expand All @@ -89,80 +70,72 @@ def do_popup(event):
# make sure to release the grab (Tk 8.0a1 only)
self.popup.grab_release()

#Create Treeview
# Create Treeview
win2 = Toplevel(self.parent)
new_element_header=file_list
new_element_header = file_list
treeScroll = Scrollbar(win2)
treeScroll.pack(side=RIGHT, fill=Y)
title_string = "F:Entity/Chunk"
self.tree = Treeview(win2, columns=[title_string]+file_list, show="headings")
self.tree = Treeview(win2, columns=[title_string] + file_list, show="headings")

self.tree.heading(title_string, text=title_string, anchor=CENTER)
self.tree.column(title_string, stretch=YES, minwidth=50, width=100, anchor=CENTER)
for each_file in file_list:
self.tree.heading(each_file, text=each_file, anchor=CENTER)
self.tree.column(each_file, stretch=YES, minwidth=50, width=100, anchor=CENTER)
for idx in range(len(file_list)):
self.tree.insert("" , 'end', text=file_list[idx], values=[file_list[idx]]+result_matrix[idx], tags = ('chart',))
the_font=('TkDefaultFont', 18, )
self.tree.insert("", 'end', text=file_list[idx], values=[file_list[idx]] + result_matrix[idx],
tags=('chart',))
the_font = ('TkDefaultFont', 18,)
self.tree.tag_configure('chart', font=the_font)
style = Style()
style.configure(".", font=the_font, )
style.configure("Treeview", )
style.configure("Treeview.Heading",font=the_font, ) #<----
style.configure("Treeview.Heading", font=the_font, ) # <----
self.tree.pack(side=TOP, fill=BOTH)
# self.tree.grid()

self.tree.bind("<Button-3>", do_popup)

win2.minsize(30,30)
win2.minsize(30, 30)

def selection(self):
print self.popup.selection

print(self.popup.selection)

def multiFiles(self):
ftypes = [('ann files', '.ann')]
filez = tkFileDialog.askopenfilenames(parent=self.parent, filetypes = ftypes, title='Choose a file')
filez = tkFileDialog.askopenfilenames(parent=self.parent, filetypes=ftypes, title='Choose a file')
if len(filez) < 2:
tkMessageBox.showinfo("Monitor Error", "Selected less than two files!\n\nPlease select at least two files!")
else:
result_matrix = generate_report_from_list(filez)
result_matrix = generate_report_from_list(filez)
self.ChildWindow(filez, result_matrix)


def compareTwoFiles(self):
ftypes = [('ann files', '.ann')]
filez = tkFileDialog.askopenfilenames(parent=self.parent, filetypes = ftypes, title='Choose a file')
filez = tkFileDialog.askopenfilenames(parent=self.parent, filetypes=ftypes, title='Choose a file')
if len(filez) != 2:
tkMessageBox.showinfo("Compare Error", "Please select exactly two files!")
else:
f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".tex")
write_result = compareBoundary(filez[0],filez[1],f)
outfile = tkFileDialog.asksaveasfilename(defaultextension=".tex")
write_result = compareBoundary(filez[0], filez[1], outfile)
if write_result:
tkMessageBox.showinfo("Latex Generate", "Latex file generated successfully!\n\nSaved to "+ f.name)
tkMessageBox.showinfo("Latex Generate", "Latex file generated successfully!\n\nSaved to " + outfile)
# import os
# os.system("pdflatex "+ f.name)
else:
tkMessageBox.showinfo("Latex Error", "Latex generated Error, two files don't have same sentence number!")
f.close()


tkMessageBox.showinfo("Latex Error",
"Latex generated Error, two files don't have same sentence number!")


def main():
print("SUTDAnnotator launched!")
print(("OS:%s")%(platform.system()))
print(("OS:%s") % (platform.system()))
root = Tk()
root.geometry("400x100")
app = Example(root)

root.mainloop()
root.mainloop()


if __name__ == '__main__':
main()





2 changes: 1 addition & 1 deletion configs/default.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"a": "Artifical", "c": "Fin-Concept", "b": "Event", "e": "Organization", "d": "Location", "g": "Sector", "f": "Person", "h": "Other"}
{'a': 'Artificial', 'b': 'Event', 'c': 'Fin-Concept', 'd': 'Location', 'e': 'Organization', 'f': 'Person', 'g': 'Sector', 'h': 'Other'}
Loading

0 comments on commit 5fd888d

Please sign in to comment.