Skip to content

Commit

Permalink
it's workinggit status
Browse files Browse the repository at this point in the history
  • Loading branch information
ned2 committed Oct 20, 2017
1 parent 9372961 commit 6d8ee74
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.python-version
typediff/config.py
typediff/settings.py

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
1 change: 0 additions & 1 deletion run-web
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export PYTHONPATH=${SCRIPTPATH}:${PYTHONPATH}
mod_wsgi-express start-server \
--debug-mode \
--reload-on-changes \
--url-alias /static www/static \
--document-root www \
--directory-index index.html \
--entry-point wsgi.py
43 changes: 0 additions & 43 deletions configs/config_example.py → settings/settings_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import os


"""
This file contains configuration information that typediff needs to
run, as well as options which can be customized.
Expand All @@ -26,17 +23,6 @@
ACESRC = None


# The path to the directory of the typediff program. Needed for other
# defaults. You should not need to change this.
TYPEDIFF_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')


# Path where ACE output will be logged to. This is useful to change if
# your web server does not have write access to the typediff
# directory.
LOGPATH = os.path.join(TYPEDIFF_PATH, 'ace.log')


# Grammars configured for use with typediff. The string '${LOGONROOT}'
# Will be replaced with the value of the LOGONROOT environment
# variable.
Expand Down Expand Up @@ -124,32 +110,3 @@
'json' : 'tanaka.json',
}
)


# The order types are to be displayed in the output list and their
# color value for terminal output and web interface output
# repectively.
#
# format = (super_type_name, terminal_color, web_color)
#
# terminal_color must be one of {white, cyan, purple, blue,
# yellow, green, red}
#
# web_color can be any valid CSS color string
TYPES = (
('sign', 'red', 'rgba(255, 0, 0, 0.65)'),
('head', 'purple', 'rgba(128, 0, 128, 0.65)'),
('synsem', 'green', 'rgba(0, 128, 0, 0.65)'),
('cat', 'blue', 'rgba(0, 0, 255, 0.65)'),
('relation', 'cyan', 'rgba(0, 255, 255, 0.65)'),
('predsort', 'yellow', 'rgba(255, 255, 0, 0.65)'),
('other', 'white', 'rgba(255, 255, 255, 1.00)'),
)


# These should only need to be changed if you needed to compile
# thebinaries for your own environment.
TYPIFIERBIN = os.path.join(TYPEDIFF_PATH, 'bin', 'typifier')
DUMPHIERARCHYBIN = os.path.join(TYPEDIFF_PATH, 'bin', 'dumphierarchy')
ACEBIN = os.path.join(TYPEDIFF_PATH, 'bin', 'ace')
JSONPATH = 'www/json'
46 changes: 2 additions & 44 deletions configs/config_hum.py → settings/settings_hum.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import os


"""
This file contains configuration information that typediff needs to
run, as well as options which can be customized.
"""

# The path to the src directory in the typediff program. Needed for
# other defaults. You no not need to change this.
_SRC_PATH = os.path.dirname(os.path.realpath(__file__))


# Directory where dat, xml and pickle files are kept.
# You'll want to change this if you don't want to store
# large amounts of data in the installation directory.
DATAPATH = os.path.join(_SRC_PATH, '..', 'grammar-data')
DATAPATH = '/home/nejl/data/grammar-data'


# Path to the directory where ace was compiled. Optionally used to
Expand All @@ -27,17 +19,12 @@
LTDBPATH = '/ltdb/cgi-bin'


# Path where ACE output will be logged to. This is useful to change if
# your web server does not have write access to the typediff
# directory.
LOGPATH = os.path.join(_SRC_PATH, '..', 'ace.log')


# For setting the LOGONROOT with apache, specify it here. Note that
# this is not actually required for running the typediff interface and
# can be left blank.
LOGONROOT = ''


# Grammars configured for use with typediff. The string '${LOGONROOT}'
# Will be replaced with the value of the LOGONROOT environment
# variable.
Expand Down Expand Up @@ -182,32 +169,3 @@
'json' : 'tanaka.json',
}
)


# The order types are to be displayed in the output list and their
# color value for terminal output and web interface output
# repectively.
#
# format = (super_type_name, terminal_color, web_color)
#
# terminal_color must be one of {white, cyan, purple, blue,
# yellow, green, red}
#
# web_color can be any valid CSS color string
TYPES = (
('sign', 'red', 'rgba(255, 0, 0, 0.65)'),
('head', 'purple', 'rgba(128, 0, 128, 0.65)'),
('synsem', 'green', 'rgba(0, 128, 0, 0.65)'),
('cat', 'blue', 'rgba(0, 0, 255, 0.65)'),
('relation', 'cyan', 'rgba(0, 255, 255, 0.65)'),
('predsort', 'yellow', 'rgba(255, 255, 0, 0.65)'),
('other', 'white', 'rgba(255, 255, 255, 1.00)'),
)


# These should only need to be changed if you needed to compile
# thebinaries for your own environment.
TYPIFIERBIN = os.path.join(_SRC_PATH, '..', 'bin', 'typifier')
DUMPHIERARCHYBIN = os.path.join(_SRC_PATH, '..', 'bin', 'dumphierarchy')
ACEBIN = os.path.join(_SRC_PATH, '..', 'bin', 'ace')
JSONPATH = 'www/json'
27 changes: 0 additions & 27 deletions typediff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +0,0 @@
import os
import sys

from . import config

root_dir = os.path.dirname(os.path.abspath(__file__))

# default params
ACEBIN = os.path.join(root_dir, 'bin', 'ace')
TYPIFIERBIN = os.path.join(root_dir, 'bin', 'typifier')
DUMPHIERARCHYBIN = os.path.join(root_dir, 'bin', 'dumphierarchy')
JSONPATH = os.path.join(root_dir, 'www', 'json')
LOGPATH = os.path.join('ace.log')


# update any values from user config if set

params = [
'ACEBIN',
'JSONPATH',
'LOGPATH',
]

for param in params:
if hasattr(config, param):
value = getattr(config, param)
setattr(sys.modules[__name__], param, value)
52 changes: 52 additions & 0 deletions typediff/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import sys

from . import settings

ROOT_PATH = os.path.dirname(os.path.abspath(__file__))

# default params
ACEBIN = os.path.join(ROOT_PATH, 'bin', 'ace')
TYPIFIERBIN = os.path.join(ROOT_PATH, 'bin', 'typifier')
DUMPHIERARCHYBIN = os.path.join(ROOT_PATH, 'bin', 'dumphierarchy')
LOGPATH = os.path.join('ace.log')

# The order types are to be displayed in the output list and their
# color value for terminal output and web interface output
# repectively.
#
# format = (super_type_name, terminal_color, web_color)
#
# terminal_color must be one of {white, cyan, purple, blue,
# yellow, green, red}
#
# web_color can be any valid CSS color string
TYPES = (
('sign', 'rgba(255, 0, 0, 0.65)', 'red'),
('synsem', 'rgba(0, 128, 0, 0.65)', 'green'),
('head', 'rgba(128, 0, 128, 0.65)', 'blue'),
('cat', 'rgba(0, 0, 255, 0.65)', 'purple'),
('relation', 'rgba(0, 255, 255, 0.65)', 'cyan'),
('predsort', 'rgba(255, 255, 0, 0.65)', 'yellow'),
('other', 'rgba(255, 255, 255, 1.00)', 'white'),
)


# get other values from settings any already defined above will be overridden

PARAMS = [
'DATAPATH',
'LOGONROOT',
'FANGORNPATH',
'LTDBPATH',
'ACESRC',
'GRAMMARLIST',
'TREEBANKLIST',
'ACEBIN',
'JSONPATH',
'LOGPATH',
]

for param in PARAMS:
if hasattr(settings, param):
setattr(sys.modules[__name__], param, getattr(settings, param))
3 changes: 1 addition & 2 deletions typediff/grammar_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import pickle
from subprocess import Popen, PIPE

from typediff import ACEBIN, DUMPHIERARCHYBIN
from .delphin import TypeHierarchy
from .config import ACESRC, DATAPATH
from .config import ACESRC, DATAPATH, ACEBIN, DUMPHIERARCHYBIN
from .gram import get_grammar, get_grammars


Expand Down
3 changes: 1 addition & 2 deletions typediff/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from flask import Flask, request, jsonify

from .config import LOGONROOT, TREEBANKLIST, FANGORNPATH, JSONPATH
from .config import LOGONROOT, TREEBANKLIST, FANGORNPATH
from .gram import get_grammar, get_grammars
from .delphin import init_paths, JSONEncoder, load_hierarchy, Treebank

Expand Down Expand Up @@ -74,5 +74,4 @@ def load_data():
'grammars' : get_grammars(),
'treebanks' : [Treebank(t) for t in TREEBANKLIST] ,
'fangornpath' : FANGORNPATH,
'jsonpath' : JSONPATH,
})
3 changes: 1 addition & 2 deletions www/static/typediff.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ function doDiff() {
// check to see if the treebank has already been loaded
// before making a request to fetch it
if (treebank.data == undefined)
requests.push($.getJSON(JSONPATH + '/' + treebank.json));
requests.push($.getJSON('/json/' + treebank.json));
}

// process the array of requests
Expand Down Expand Up @@ -1118,7 +1118,6 @@ function loadData(callback) {
var posting = $.post('/load-data');
posting.done(function(data) {
FANGORNPATH = data.fangornpath;
JSONPATH = data.jsonpath;
GRAMMARS = {};
var $grammarInput = $('#grammar-input');
var $treebankInput = $('#treebank-input');
Expand Down

0 comments on commit 6d8ee74

Please sign in to comment.