From fa047e0171f3fb9887722045fbdba12849ea84a4 Mon Sep 17 00:00:00 2001 From: einarr Date: Mon, 8 Jan 2007 21:13:22 +0000 Subject: [PATCH] Committing non-working code that breaks go workflow. ;) --- workflows/go_workflow.py | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/workflows/go_workflow.py b/workflows/go_workflow.py index dcd833f..37c1694 100644 --- a/workflows/go_workflow.py +++ b/workflows/go_workflow.py @@ -132,6 +132,53 @@ class LoadGOFunction(workflow.Function): fluents.app['bottom_notebook'].append_page(browser, label) +class LoadTextDatasetFunction(workflow.Function): + + def __init__(self): + workflow.Function.__init__(self, 'load-text-ds', 'Load text dataset') + + def read_text_dataset(self, fd): + split_re = re.compile('^#\s*(\w+)\s*:\s*(.)') + dimensions = [] + identifiers = {} + type = 'dataset' + name = 'Unnamed dataset' + + # Read header lines from file. + line = fd.readline() + while line: + m = split_re.match(line) + if m: + key, val = m + + # The line is on the form; + # dimension: dimname id1 id2 id3 ... + if key == 'dimension': + values = [v.strip() for v in val.split(' ') + dimensions.append(values[0]) + identifiers[values[0]] = values[1:] + + headers[key] = val.strip() + + # Read type of dataset. + # Should be dataset, category, or network + elif key == 'type': + type = val + + elif key == 'name': + name = val + + else: + break + line = f.readline() + + + def run(self): + f = open('/home/einarr/foodata.tds') + return read_text_dataset(f) + + + class LoadAnnotationsFunction(workflow.Function): def __init__(self):