Skip to content
Snippets Groups Projects
Commit f5176d86 authored by jezozwierzak's avatar jezozwierzak
Browse files

repaired tabs in subheads

parent 4af354c0
Branches
No related merge requests found
......@@ -93,11 +93,12 @@ class CSVColumn:
self.recountWidths()
else:
assert type(data).__name__ != 'dict', 'You added dict to column with no subcolumns'
if len(self.content) == 0:
self.type = type(data).__name__
self.content.append(data)
if len(str(data)) > self.width and self.isSubColumn():
self.parent.recountWidths()
self.parent.recountWidths(self.parent.content.index(self))
elif len(str(data) + self.separator) > self.width:
self.width = len(str(data))
......@@ -113,7 +114,7 @@ class CSVColumn:
result += row
return result
def recountWidths(self):
def recountWidths(self, sub=''):
subColsStr = ''
for subColumn in self.content:
subColsStr += subColumn.name + self.separator
......@@ -122,10 +123,23 @@ class CSVColumn:
self.width = len(subColsStr)
for subColumn in self.content:
subColumn.width = len(subColumn.name + self.separator)
elif self.parent.rows > 0:
if len(self.content[0].content) > 0:
widths = 0
for i in range(0,len(self.content)): #Dla każdej podkolumny
for j in range(0, self.parent.rows): #Dla każdego wiersza
if sub == '':
for i in range(0,len(self.content)): #Dla każdej podkolumny
for j in range(0, len(self.content[0].content)): #Dla każdego wiersza
if i == len(self.content) - 1:
if self.width - widths > 0:
self.content[i].width = self.width - widths
else:
self.content[i].width = len(self.parent.ptr(self.content[i].content[j], 1))
break
elif len(self.parent.ptr(self.content[i].content[j], 1)) > self.content[i].width:
self.content[i].width = len(self.parent.ptr(self.content[i].content[j], 1))
widths += self.content[i].width
else:
i = sub
for j in range(0, len(self.content[0].content)): #Dla każdego wiersza
if i == len(self.content) - 1:
if self.width - widths > 0:
self.content[i].width = self.width - widths
......
......@@ -159,6 +159,7 @@ def main(ch_path, ref_path, chan_names, input_format, out_path, tagset, verbose,
# process each sentence separately
for ch_sent, ref_sent in zip(ch_chunk.sentences(), ref_chunk.sentences()):
print ch_sent.size(), ref_sent.size()
assert ch_sent.size() == ref_sent.size()
ch_annots = get_annots(ch_sent, chan_name)
ref_annots = get_annots(ref_sent, chan_name)
......@@ -166,14 +167,15 @@ def main(ch_path, ref_path, chan_names, input_format, out_path, tagset, verbose,
results[chan_name] = stats.getStats()
csvTable.addRow(results)
# csvTable.countAvg()
csvTable.countAvg()
if out_path != '':
out = codecs.open(out_path, "w", "utf-8")
out.write(csvTable.__str__())
out.close()
else:
print csvTable
if __name__ == '__main__':
go()
\ No newline at end of file
go()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment