Skip to content

Commit 5700030

Browse files
committed
Hacky fix to when multihyp ref alignments misaligned
1 parent 38e9013 commit 5700030

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class BuildExt(build_ext):
7373
def build_extensions(self):
7474
ct = self.compiler.compiler_type
7575
opts = self.c_opts.get(ct, [])
76+
#opts.append('-g')
7677
if ct == "unix":
7778
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
7879
opts.append(cpp_flag(self.compiler))

tests/test_functions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,18 @@ def test_speed():
354354
logger.add(sys.stdout, level='INFO')
355355
ref = create_inp(open('tests/reftext').read().splitlines())
356356
hyp = create_inp(open('tests/hyptext').read().splitlines())
357-
import cProfile
358-
pr = cProfile.Profile()
357+
# import cProfile
358+
# pr = cProfile.Profile()
359+
# pr.enable()
359360

360-
pr.enable()
361361
buffer = io.StringIO()
362362
start_time = time.perf_counter()
363363
texterrors.process_output(ref, hyp, fh=buffer, ref_file='ref', hyp_file='hyp',
364364
skip_detailed=True, use_chardiff=True, debug=False)
365365
process_time = time.perf_counter() - start_time
366366

367-
pr.disable()
368-
pr.dump_stats('speed.prof')
367+
# pr.disable()
368+
# pr.dump_stats('speed.prof')
369369

370370
logger.info(f'Processing time for speed test is {process_time}')
371371
assert process_time < 2.

texterrors/texterrors.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,18 @@ def _merge_multilines(multilines_a, multilines_b, terminal_width, usecolor):
603603
idx_b += 1
604604

605605
else:
606-
print(le_a, le_b, _remove_color(le_a.words[0]), _remove_color(le_b.words[0]))
607-
raise RuntimeError('Should not be possible AA')
606+
logger.warning('Weird case!! found please report')
607+
refword = le_a[0] + '|' + le_b[0]
608+
if usecolor:
609+
refword = colored(refword, 'green', force_color=True)
610+
if le_a[0] != hyp_worda:
611+
hyp_worda = colored(hyp_worda, 'red', force_color=True)
612+
if le_b[0] != hyp_wordb:
613+
hyp_wordb = colored(hyp_wordb, 'red', force_color=True)
614+
multiline.add_lineelement(refword, hyp_worda, hyp_wordb)
615+
idx_a += 1
616+
idx_b += 1
617+
608618
while idx_a < len(multiline_a):
609619
assert idx_b == len(multiline_b)
610620
le_a = multiline_a[idx_a]

0 commit comments

Comments
 (0)