summaryrefslogtreecommitdiff
path: root/src/functionalizer.py
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2014-04-25 18:40:18 +0200
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2014-04-25 18:40:18 +0200
commit7120911494711094c6dcd9dc0da741d686207aab (patch)
tree9eb85690b3550d810796ebed2328631001f4405b /src/functionalizer.py
parent145368964385a6e8d475d10e2b726bf18a33d2f1 (diff)
modificationsHEADmaster
Diffstat (limited to 'src/functionalizer.py')
-rw-r--r--src/functionalizer.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/functionalizer.py b/src/functionalizer.py
index 66325a0..782b4e5 100644
--- a/src/functionalizer.py
+++ b/src/functionalizer.py
@@ -37,6 +37,37 @@ class Functionalizer:
break
counter += 1
+ def run_sentence(self, experiment_dir, temp_dir):
+ hyp_file = open('%s/nbest.tmp' % temp_dir, 'r')
+
+ hypsets = []
+ hypset = []
+ last_eid = 0
+ for line in hyp_file:
+ parts = line.split('|||')
+ eid = int(parts[0])
+ if eid != last_eid:
+ hypsets.append(hypset)
+ hypset = []
+ last_eid = eid
+ score = parts[2] + ' ||| ' + parts[3].strip()
+ hyp = parts[1].strip()
+ hypset.append((hyp,score))
+ hypsets.append(hypset)
+ hyp_file.close()
+
+ counter = 0
+ for hypset in hypsets:
+ hypset = list(reversed(hypset))
+ while hypset:
+ hyp, score = hypset.pop()
+ fun = self.functionalize(hyp)
+ if fun:
+ return fun
+ break
+ counter += 1
+ return ""
+
#xc = 0
def functionalize(self, mrl):