Skip to content

Commit

Permalink
arrange to current version
Browse files Browse the repository at this point in the history
  • Loading branch information
Wei-Te Chen committed Jan 14, 2016
1 parent df3ee95 commit 7a3f98b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 72 deletions.
3 changes: 3 additions & 0 deletions src/main/annotate/anaforaProjectManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def searchAvailableTask(projectName, corpusName, schemaName, annotator, projectM
if os.path.isdir(corpusPath) != True:
raise IOError("project or corpus name error")

if mode.directSetGold:
maxNumOfAnnotator = 1

for taskName in [tName for tName in os.listdir(corpusPath) if os.path.isdir(os.path.join(corpusPath, tName)) and tName[0] != '.']:
taskPath = os.path.join(corpusPath, taskName)
numOfAnnotatorFile = 0
Expand Down
6 changes: 4 additions & 2 deletions src/main/annotate/projectSetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ def getMode(self, modeName):
return mode

class Mode():
def __init__(self, name, needPreannotation = False, preannotationFromMode = None, schemaFile = []):
def __init__(self, name, needPreannotation = False, preannotationFromMode = None, schemaFile = [], directSetGold = False):
self.name = name
self.needPreannotation = needPreannotation
self.preannotationFromMode = preannotationFromMode
self.directSetGold = directSetGold
self.schemaFile = schemaFile

def addSchemaFile(self, newSchemaFile):
Expand All @@ -185,14 +186,15 @@ def parseFromXMLDOM(cls, modeNode):
preannotationFromMode = None
if isPreannotation:
preannotationFromMode = modeNode.getAttribute("preannotationFrom")
directSetGold = (modeNode.getAttribute("directSetGold").lower() == "true")
schemaFileList = []
for childNode in [tNode for tNode in modeNode.childNodes if tNode.nodeType == tNode.ELEMENT_NODE]:
if childNode.tagName == "file":
schemaFileList.append(childNode.childNodes[0].nodeValue)
else:
raise Exception("unhandle tag: " + childNode.tagName)

return cls(name, isPreannotation, preannotationFromMode, schemaFileList)
return cls(name, isPreannotation, preannotationFromMode, schemaFileList, directSetGold)

class Project():
def __init__(self, name, admins , numOfAnnotator = 2, annotators = [], allowedSchemas = []):
Expand Down
8 changes: 2 additions & 6 deletions src/main/annotate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def index(request, projectName="", corpusName="", taskName="", schema="", schema
except:
return HttpResponseForbidden("raw text file open error: " + rawTextFile)


account = request.META["REMOTE_USER"]
ps = getProjectSetting()
schemaMap = ps.getSchemaMap()
Expand Down Expand Up @@ -312,20 +311,17 @@ def setCompleted(request, projectName, corpusName, taskName, schemaName):
if os.path.exists(fileName + ".inprogress.xml"):
subprocess.call(["mv", fileName + ".inprogress.xml", fileName + ".completed.xml"])
subprocess.call("sed -u -i 's/<progress>in-progress<\/progress>/<progress>completed<\/progress>/' " + fileName + ".completed.xml", shell=True)

if "-Adjudication" in schemaName:
mode = ps.getMode(*(schemaName.replace("-Adjudication", "").split("-")))
if "-Adjudication" in schemaName or mode.directSetGold:
# set as gold
fileNameGold = filePath + "/" + taskName + "." + schemaName.replace("-Adjudication", "") + ".gold.completed.xml"
subprocess.call(["cp", fileName + ".completed.xml", fileNameGold])
schema = ps.getSchema(schemaName.split("-")[0])
mode = ps.getMode(*(schemaName.replace("-Adjudication", "").split("-")))
for tMode in schema.modes:
if tMode.needPreannotation and tMode.preannotationFromMode == mode:
fileNamePreannotation = filePath + "/" + taskName + "." + schema.name + "-" + tMode.name + ".preannotation.completed.xml"
subprocess.call(["cp", fileNameGold, fileNamePreannotation])



return HttpResponse()
else:
return HttpResponseNotFound("in-progress file not found")
Expand Down
6 changes: 0 additions & 6 deletions src/main/static/js/annotate/annotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var projectSelector = undefined;
var editable = false;
var propertyFrameList = [];
var relationFrame = undefined;

var isChanged = false;

function onLoad() {
Expand Down Expand Up @@ -596,11 +595,6 @@ function registerHotkey(schema) {
body.bind("keydown", key, function(evt) {if(!checkEmptyProperty()) return false; addNewAObj(schema.hotkeyDict[evt.data]);});
}

// +
body.bind("keydown", "+", function(evt) {
alert("+");
});

// space
body.bind("keydown", function(evt) {
switch(evt.which){
Expand Down
49 changes: 1 addition & 48 deletions src/main/static/js/annotate/projectSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,47 +139,6 @@ ProjectSelector.prototype.getAnnotator = function(projectName, corpusName, taskN
return annotator;
}

/*
ProjectSelector.prototype.getCorpusFromProjectName = function(projectName) {
if(projectName in this.projectDir) {
if(Object.keys(this.projectDir[projectName]).length === 0) {
//var corpusJSON = $.ajax({ type: "GET", url: _setting.root_url + "/" + _setting.app_name + "/getDir/" + projectName + "/", cache: false, async: false}).responseText;
//var corpusList = $.parseJSON(corpusJSON);
var corpusList = this.getDir(projectName);
var _self = this;
$.each(corpusList, function(index, element) {
_self.projectDir[projectName][element] = null;
});
}
}
return this.projectDir[projectName];
}
*/

/*
ProjectSelector.prototype.getTaskFromProjectCorpusName = function(projectName, corpusName) {
var taskJSON = "";
*/
/*
if(this.adjudication) {
var adjSrcSchemaModeList = Object.keys(_setting.schemaMap[this.schema]).sort();
var adjIdx = adjSrcSchemaModeList.indexOf("Adjudication");
var adjSrcSchemaMode = adjSrcSchemaModeList[(adjIdx+1) % adjSrcSchemaModeList.length];
taskJSON = $.ajax({ type: "GET", url: _setting.root_url + "/" + _setting.app_name + "/getDir/" + projectName + "/" + corpusName + "/" + this.schema + "." + adjSrcSchemaMode + "/" + this.schema + (this.mode==undefined ? "" : "."+this.mode) + "/" , cache: false, async: false}).responseText;
}
else
taskJSON = $.ajax({ type: "GET", url: _setting.root_url + "/" + _setting.app_name + "/getDir/" + projectName + "/" + corpusName + "/" + this.schema + (this.mode==undefined ? "" : "."+this.mode) + "/" , cache: false, async: false}).responseText;
var taskList = $.parseJSON(taskJSON);
*/
/*
taskList = this.getDir(projectName, corpusName, this.schema, this.isAdjudication);
return taskList;
}
*/

ProjectSelector.prototype.selectProject = function() {
this.updateSelectMenu("Select Project" ,Object.keys(this.projectDir), ProjectSelector.clickProject);
Expand Down Expand Up @@ -256,7 +215,7 @@ ProjectSelector.prototype.openNewProject = function() {
throw "openNewProject error: required selected project, corpus, task or schema";


window.location = this.baseURL + this.selected.project + "/" + this.selected.corpus + "/" + this.selected.task + "/" + this.schema + (this.mode === false || this.mode===undefined ? "" : "."+this.mode) + (this.adjudication ? ".Adjudication" : "" ) + "/" + ((this.view != undefined && this.view) ? this.selected.annotator : "") ;
window.location = this.baseURL + this.selected.project + "/" + this.selected.corpus + "/" + this.selected.task + "/" + this.schema + (this.mode === false || this.mode===undefined ? "" : "."+this.mode) + (this.adjudication ? ".Adjudication" : "" ) + "/" + ((this.view != undefined && this.view) ? (this.selected.annotator ) : "") ;
}

ProjectSelector.clickProject = function(_self, target ) {
Expand Down Expand Up @@ -428,12 +387,6 @@ ProjectSelector.clickViewSelect = function(_self, target) {
_self.view = !_self.view;
_self.viewSelect();
}
/*
ProjectSelector.clickAdjudicationReelect = function(_self, target) {
_self.adjudication = false;
_self.adjudicationSelect();
}
*/
ProjectSelector.prototype.modeSelect = function() {
var _self = this;
if(this.schema != undefined && this.mode !== false) {
Expand Down
28 changes: 18 additions & 10 deletions src/main/web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# URLthat handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
Expand All @@ -62,16 +62,24 @@

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_ROOT = '/data/home/verbs/student/wech5560/Research/anaforaDevelop/src/main/static'
#STATIC_ROOT = '/data/home/verbs/student/wech5560/Research/TemporalPreAnnotation/main/StaticFiles'
STATIC_URL = '/static/'

ROOT_URL = '/anafora'
ROOT_URL = '/~wech5560/anafora'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
''
)
'',
'/data/home/verbs/student/wech5560/Research/anaforaDevelop/src/main/static',
)
# /data/home/verbs/student/wech5560/Research/anaforaDevelop/src/main/static',
# '/data/home/verbs/student/wech5560/Research/anaforaDevelop/src/main/static/css',
# '/data/home/verbs/student/wech5560/Research/anaforaDevelop/src/main/static/js',
# '/data/home/verbs/student/wech5560/Research/anaforaDevelop/src/main/static/image',
#)

# List of finder classes that know how to find static files in
# various locations.
Expand All @@ -82,7 +90,7 @@
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = ''
SECRET_KEY = 'hellla293ujlkdjfl;1393@@9fji'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
Expand All @@ -105,7 +113,7 @@
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
# Uncomment the next line for Anafora digest auth
'annotate.anaforaAuthMiddleware.AnaforaAuthMiddleware',
#'annotate.anaforaAuthMiddleware.AnaforaAuthMiddleware',
)

ROOT_URLCONF = 'web.urls'
Expand All @@ -114,14 +122,12 @@
WSGI_APPLICATION = 'web.wsgi.application'

TEMPLATE_DIRS = (
""
"/data/home/verbs/student/wech5560/Research/anaforaDevelop/src/Templates"
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)



INSTALLED_APPS = (
# 'django.contrib.auth',
# 'django.contrib.contenttypes',
Expand Down Expand Up @@ -170,10 +176,12 @@
TEST_RUNNER = 'testing.DatabaselessTestRunner'

# Assign the anafora project file directory path
ANAFORA_PROJECT_FILE_ROOT = ""
#ANAFORA_PROJECT_FILE_ROOT = ""
ANAFORA_PROJECT_FILE_ROOT = "/data/home/verbs/student/wech5560/Research/KnowtatorProcessing/data/anaforaProjectFile/"

# Assign the Digest auth group file location
GROUP_FILE = ''
#GROUP_FILE = '/data/anafora-event/site/anafora-event.group'

# Assign the group name for the admin
ADMIN_GROUPNAME = 'anaforaadmin'
Expand Down

0 comments on commit 7a3f98b

Please sign in to comment.