diff --git a/scripts/chunker_scripts/chunk_eval/chunk_eval.py b/scripts/chunker_scripts/chunk_eval/chunk_eval.py index b1e65b3c1bab7ffcf6458c0890b2f2017bc3d0a9..cda686412eb97e17136401e155876bcd03d503b2 100755 --- a/scripts/chunker_scripts/chunk_eval/chunk_eval.py +++ b/scripts/chunker_scripts/chunk_eval/chunk_eval.py @@ -20,7 +20,7 @@ Created on 01-08-2012 from optparse import OptionParser import corpus2 import sys, os -from chunker_scripts2.csv_table import CSVTable +from chunker_scripts.csv_table.CSVTable import CSVTable import codecs descr = """%prog [options] CHUNKED REF @@ -92,7 +92,7 @@ def get_annots(sent, chan_name): ann_vec = chan.make_annotation_vector() for ann in ann_vec: assert ann.head_index in ann.indices - annots.appendCell(ann) + annots.append(ann) return annots def go(): diff --git a/scripts/chunker_scripts/csv_table/CSVColumn.py b/scripts/chunker_scripts/csv_table/CSVColumn.py index 784468aa03e1bd9f4618bf4141f6a61d01492732..59e315ac45ec62b816b0677304ef1539d17e1160 100755 --- a/scripts/chunker_scripts/csv_table/CSVColumn.py +++ b/scripts/chunker_scripts/csv_table/CSVColumn.py @@ -30,7 +30,7 @@ class CSVColumn: def addSubColumn(self, name, type = ''): assert len(self.content) == 0 or self.hasSubColumns() self.type = 'dict' - self.content.appendCell(CSVColumn(self, name, self.separator, type)) + self.content.append(CSVColumn(self, name, self.separator, type)) self.recountWidths() def insertValue(self, row, data, subColumn =''): @@ -96,7 +96,7 @@ class CSVColumn: if len(self.content) == 0: self.type = type(data).__name__ - self.content.appendCell(data) + self.content.append(data) if len(str(data)) > self.width and self.isSubColumn(): self.parent.recountWidths(self.parent.content.index(self)) elif len(str(data) + self.separator) > self.width: @@ -171,10 +171,10 @@ class CSVColumn: else: for i in range(0, rows): if self.type == "float": - self.content.appendCell(0.0) + self.content.append(0.0) elif self.type == "int": - self.content.appendCell(0) + self.content.append(0) else: - self.content.appendCell('') + self.content.append('') \ No newline at end of file diff --git a/scripts/chunker_scripts/csv_table/CSVTable.py b/scripts/chunker_scripts/csv_table/CSVTable.py index 247bc673c281110cfe2c21b38055b6c96f55c0ae..12c6c617cf80ba3cd0493d189c9a1bf57b73c595 100755 --- a/scripts/chunker_scripts/csv_table/CSVTable.py +++ b/scripts/chunker_scripts/csv_table/CSVTable.py @@ -35,7 +35,7 @@ class CSVTable: for column in self.content: assert column.name != name, 'Column with name: '+ name+ ' already exists' column = CSVColumn(self, name, self.separator, type) - self.content.appendCell(column) + self.content.append(column) if self.rows > 0 and type != 'dict': column.fillZeros(self.rows) diff --git a/scripts/chunker_scripts/experiments/oracle.py b/scripts/chunker_scripts/experiments/oracle.py index 8dd6ec25eeafca7eb771269763cebf1e0359ca50..ed373ecd42f4e61f211498b085f8945ff0deeb25 100755 --- a/scripts/chunker_scripts/experiments/oracle.py +++ b/scripts/chunker_scripts/experiments/oracle.py @@ -10,7 +10,7 @@ import sys, os import corpus2 from chunker_scripts import tools -descr = """%prog [options] [in_dir] [out_dir] +descr = """%prog [options] [in_dir] [ref_dir] [out_dir] in_dir has to contain subdirs with folds chunked by individual chunkers. Subdir should be named as chunker which chunked files in it. """ diff --git a/scripts/chunker_scripts/stats/count_not_cont.py b/scripts/chunker_scripts/stats/count_not_cont.py old mode 100644 new mode 100755 index e70fd7ff53fde7f747adff3b8d8729703cdb377b..499e0e808b5cb4fdaa456e72cba1586e5c7d716f --- a/scripts/chunker_scripts/stats/count_not_cont.py +++ b/scripts/chunker_scripts/stats/count_not_cont.py @@ -7,9 +7,7 @@ Created on Mar 25, 2013 ''' from optparse import OptionParser import sys, os - -from csv_table2.csv_table import CsvTable - +from chunker_scripts import tools import corpus2 descr="""%prog [options] in_dir out_dir @@ -22,12 +20,6 @@ def go(): parser.add_option('-i', '--input-format', type='string', action='store', dest='input_format', default='ccl', help='set the input format; default: ccl') - parser.add_option('-o', '--output-format', type='string', action='store', - dest='output_format', default='ccl', - help='set the output format; default: ccl') - parser.add_option('-O', '--output-file', type='string', action='store', - dest='out_path', default='', - help='set output filename (do not write to stdout)') parser.add_option('-c', '--chunk-names', type='string', action='store', dest='chunk_names', default='chunk_np,chunk_vp,chunk_adjp,chunk_agp', help='set chunk_names to count') @@ -68,26 +60,6 @@ def get_input_paths(in_path, folds, input_format): input_paths.append(in_path) return input_paths - -def get_writer(out_path, output_format, tagset): - if out_path: - return corpus2.TokenWriter.create_path_writer(output_format, out_path, - tagset) - else: - return corpus2.TokenWriter.create_stdout_writer(output_format, tagset) - -def get_reader(in_path, input_format, tagset): - if in_path: - return corpus2.TokenReader.create_path_reader( - input_format, tagset, in_path) - else: - return corpus2.TokenReader.create_stdin_reader(input_format, tagset) - -def get_output_path(out_path, basename = None): - if basename == None: - return out_path - else: - return os.path.join(out_path, basename) def main(in_path, input_format, output_format, chunk_names, folds, tagset): tagset = corpus2.get_named_tagset(tagset) @@ -99,7 +71,7 @@ def main(in_path, input_format, output_format, chunk_names, folds, tagset): i=0 for input_path in input_paths: - reader = get_reader(input_path, input_format, tagset) + reader = tools.get_reader(input_path, input_format, tagset) print input_path fold_results = {'all':0, 'n_c':0, '%':0} diff --git a/scripts/chunker_scripts/stats/is_name_in_chunk_np.py b/scripts/chunker_scripts/stats/is_name_in_chunk_np.py old mode 100644 new mode 100755