From 1eccc03d43ae00fb913d7e648dd2d9b62c20eb81 Mon Sep 17 00:00:00 2001 From: "trevor.cohn" Date: Sun, 18 Jul 2010 22:43:24 +0000 Subject: ?? git-svn-id: https://ws10smt.googlecode.com/svn/trunk@312 ec762483-ff6d-05da-a07a-a48fb63a330f --- gi/pyp-topics/scripts/spans2labels.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gi/pyp-topics') diff --git a/gi/pyp-topics/scripts/spans2labels.py b/gi/pyp-topics/scripts/spans2labels.py index f3968616..73ea20f2 100755 --- a/gi/pyp-topics/scripts/spans2labels.py +++ b/gi/pyp-topics/scripts/spans2labels.py @@ -20,6 +20,7 @@ if len(sys.argv) > 4: assert phr in 'stb' assert ctx in 'stb' +print >>sys.stderr, "Loading phrase index" phrase_context_index = {} for line in file(sys.argv[1], 'r'): phrase,tail= line.split('\t') @@ -37,17 +38,20 @@ for line in file(sys.argv[1], 'r'): features=dict([ keyval.split('=') for keyval in contexts[i+1].split()]) category = features['C'] if features.has_key('P') and float(features['P']) < threshold: - category = cutoff_cat + category = cutoff_cat phrase_context_index[(phrase,contexts[i])] = category -# print (phrase,contexts[i]), category, prob + #print (phrase,contexts[i]), category +print >>sys.stderr, "Labelling spans" for line in sys.stdin: line_segments = line.split('|||') source = ['' for x in range(order)] + line_segments[0].split() + ['' for x in range(order)] target = ['' for x in range(order)] + line_segments[1].split() + ['' for x in range(order)] phrases = [ [int(i) for i in x.split('-')] for x in line_segments[2].split()] + #print >>sys.stderr, "line", source, '---', target, 'phrases', phrases + print "|||", for s1,s2,t1,t2 in phrases: @@ -85,7 +89,8 @@ for line in sys.stdin: else: context = contextt - label = phrase_context_index.get((phrase,context), "") + #print "%d-%d-%d-%d looking up" % (s1-order,s2-order,t1-order,t2-order), (phrase, context) + label = phrase_context_index.get((phrase,context), cutoff_cat) if label != cutoff_cat: #cutoff'd spans are left unlabelled print "%d-%d-%d-%d:X%s" % (s1-order,s2-order,t1-order,t2-order,label), print -- cgit v1.2.3