From 543b5ae96b2b68dc3774c8cea446faa48c6ad1c4 Mon Sep 17 00:00:00 2001
From: jezozwierzak <jezozwierzak@gmail.com>
Date: Wed, 17 Oct 2012 12:24:09 +0200
Subject: [PATCH] Added option --with-heads

---
 iobber/chunker.py | 4 ++--
 iobber/iobber.py  | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/iobber/chunker.py b/iobber/chunker.py
index aacdd2f..3ad98de 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 b1febee..10947ad 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
-- 
GitLab