diff --git a/iobber/chunker.py b/iobber/chunker.py index aacdd2f9ae096ace533c039dc7c48c7fb1618306..3ad98de8a41e42ff3facdc5c26a88bc318521230 100644 --- a/iobber/chunker.py +++ b/iobber/chunker.py @@ -163,7 +163,7 @@ class Chunker: else: non_O_chan = chan_name non_O_tag = there_iob - if chan.is_head_at(tok_idx): + if self.with_heads and chan.is_head_at(tok_idx): non_O_chan += '-H' # B-NP, I-VP etc. or O class_label = 'O' if non_O_chan is None else '%s-%s' % (non_O_tag, non_O_chan) @@ -234,7 +234,7 @@ class Chunker: # TODO: rename the from_string in corpus2 and fix it here tag_to_set = 'O' if chan_name != non_O_chan else non_O_tag chan.set_iob_at(tok_idx, corpus2.from_string(tag_to_set)) - if tag_to_set != 'O' and is_head: + if tag_to_set != 'O' and is_head and self.with_heads: chan.set_head_at(tok_idx, True) # switch back to segments for chan_name in chans: diff --git a/iobber/iobber.py b/iobber/iobber.py index b1febeed9be0c649ed6a99eeb85558951aec0896..10947ad202fe977fb38c4a7c4bb134e227f7560b 100755 --- a/iobber/iobber.py +++ b/iobber/iobber.py @@ -64,6 +64,9 @@ def go(): parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='verbose mode') + parser.add_option('--with-heads', action='store_true', + dest='with_heads', default=False, + help='Training or chunking with heads mode.') parser.add_option('--train', action='store_true', dest='is_training', help='train the chunker') parser.add_option('--batch', action='store_true', @@ -78,7 +81,7 @@ def go(): files = args[1:] tagr = chunker.Chunker(config_fname, options.data_dir, - verbose = options.verbose) + verbose = options.verbose, with_heads = options.with_heads) if options.is_training: # chunker training