Skip to content
Snippets Groups Projects
Commit 8a52a5d1 authored by Adam Pawlaczek's avatar Adam Pawlaczek
Browse files

made some simple fixes in sripts

parent 82245ed9
No related branches found
No related tags found
No related merge requests found
......@@ -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():
......
......@@ -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
......@@ -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)
......
......@@ -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.
"""
......
......@@ -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')
......@@ -69,26 +61,6 @@ def get_input_paths(in_path, folds, input_format):
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)
chunk_names = chunk_names.split(",")
......@@ -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}
......
File mode changed from 100644 to 100755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment