Skip to content
This repository has been archived by the owner on Aug 15, 2020. It is now read-only.

Commit

Permalink
changed tmp dir to data/tmp instead of assuming /tmp (which is now co…
Browse files Browse the repository at this point in the history
…mpatible for windows)
  • Loading branch information
William Boag authored and William Boag committed Jul 17, 2018
1 parent 5e1599f commit 441e3d2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion code/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def main():


# create temporary directory for these files
tempdir_name = '/tmp/cliner_eval_%d' % random.randint(0,256)
cliner_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
tmp_dir = os.path.join(cliner_dir, 'data', 'tmp')
tempdir_name = os.path.join(tmp_dir, 'cliner_eval_%d' % random.randint(0,256))
#print tempdir_name

#text_dir = os.path.join(tempdir_name, 'text/')
Expand Down
3 changes: 2 additions & 1 deletion code/feature_extraction/genia_dir/interface_genia.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from subprocess import Popen, PIPE
from .genia_cache import GeniaCache

tmp_dir = '/tmp'
cliner_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
tmp_dir = os.path.join(cliner_dir, 'data', 'tmp')

def genia(geniatagger, data):

Expand Down
3 changes: 2 additions & 1 deletion code/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

import tempfile

tmp_dir = '/tmp'
cliner_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
tmp_dir = os.path.join(cliner_dir, 'data', 'tmp')

def create_filename(odir, bfile, extension):
fname = os.path.basename(bfile) + extension
Expand Down
7 changes: 5 additions & 2 deletions code/machine_learning/crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from tools import compute_performance_stats
from feature_extraction.read_config import enabled_modules

cliner_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
tmp_dir = os.path.join(cliner_dir, 'data', 'tmp')

def format_features(rows, labels=None):

retVal = []
Expand Down Expand Up @@ -125,7 +128,7 @@ def train(X, Y, val_X=None, val_Y=None, test_X=None, test_Y=None):
trainer.append(xseq, yseq)

# Train the model
os_handle,tmp_file = tempfile.mkstemp(dir='/tmp', suffix="crf_temp")
os_handle,tmp_file = tempfile.mkstemp(dir=tmp_dir, suffix="crf_temp")
trainer.train(tmp_file)

# Read the trained model into a string (so it can be pickled)
Expand Down Expand Up @@ -173,7 +176,7 @@ def predict(clf, X):
feats = format_features(X)

# Dump the model into a temp file
os_handle,tmp_file = tempfile.mkstemp(dir='/tmp', suffix="crf_temp")
os_handle,tmp_file = tempfile.mkstemp(dir=tmp_dir, suffix="crf_temp")
with open(tmp_file, 'wb') as f:
f.write(clf)

Expand Down
6 changes: 4 additions & 2 deletions code/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
from tools import print_str, print_vec, print_files, write



cliner_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
tmp_dir = os.path.join(cliner_dir, 'data', 'tmp')

class ClinerModel:

Expand Down Expand Up @@ -431,7 +432,8 @@ def generic_train(p_or_n, train_sents, train_labels, use_lstm, val_sents=None, v

print ("START TRAINING")

parameters['conll_like_result_folder']='/tmp/cliner_eval_%d' % random.randint(0,256)+os.sep
eval_dir = os.path.join(tmo_dir, 'cliner_eval_%d' % random.randint(0,256)+os.sep)
parameters['conll_like_result_folder']=eval_dir)


test_temp = os.path.join(parameters['conll_like_result_folder'], 'test/')
Expand Down
2 changes: 2 additions & 0 deletions data/tmp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 441e3d2

Please sign in to comment.