Beispiel #1
0
    def __init__(self, id, opts, input, output):

        """Initialize TarsqiControl object conform the data source identifier
        and the processing options. Does not set the instance variables related
        to the document model and the meta data.

        Arguments:
           id - data source identifier (string)
           opts - dictionary of processing options
           input - absolute path
           output - absolute path"""

        # Make sure we're in the right directory. If the toolkit
        # crached on a previous file it may end up being in a
        # different directory.
        os.chdir(TTK_ROOT)
        
        # initialize options from the settings file
        self.processing_options = read_settings('settings.txt')
        
        # user provided options
        self.data_source_identifier = id
        self.processing_options.update(opts)
        self.input = input
        self.output = output
        self.basename = os.path.basename(input)
        if self.basename.endswith('.xml'):
            self.basename = self.basename[0:-4]
        # change the type of some of the processing options
        _transform_values(self.processing_options)

        # to be filled in by document model and later processing
        self.document_model = None
        self.processing_parameters = None
        self.metadata = None
        self.xml_document = None
        self.document = None

        # directories and files, user has no control over where
        # intermediate files go
        self.DIR_GUTIME = TTK_ROOT + os.sep + 'gutime'
        self.DIR_DATA = TTK_ROOT + os.sep + 'data'
        self.DIR_DATA_TMP = self.DIR_DATA + os.sep + 'tmp'
        self.DIR_PARSED = os.path.join(self.DIR_DATA, 'in', 'parsed')
        self.FILE_PRE = self.DIR_DATA_TMP + os.sep + self.basename + '.pre.xml'
        self.FILE_GUT = self.DIR_DATA_TMP + os.sep + self.basename + '.gut.xml'
        self.FILE_EVI = self.DIR_DATA_TMP + os.sep + self.basename + '.evi.xml'
        self.FILE_SLI = self.DIR_DATA_TMP + os.sep + self.basename + '.sli.xml'
        self.FILE_S2T = self.DIR_DATA_TMP + os.sep + self.basename + '.s2t.xml'
        self.FILE_BLI = self.DIR_DATA_TMP + os.sep + self.basename + '.bli.xml'
        self.FILE_CLA = self.DIR_DATA_TMP + os.sep + self.basename + '.cla.xml'
        self.FILE_MER = self.DIR_DATA_TMP + os.sep + self.basename + '.mer.xml'
        
        self.collect_parsed_files()
Beispiel #2
0
    def __init__(self, id, opts, input, output):

        """Initialize TarsqiControl object conform the data source identifier
        and the processing options. Does not set the instance variables related
        to the document model and the meta data.

        Arguments:
           id - data source identifier (string)
           opts - dictionary of processing options
           input - absolute path
           output - absolute path"""

        # Make sure we're in the right directory. If the toolkit
        # crached on a previous file it may end up being in a
        # different directory.
        os.chdir(TTK_ROOT)
        
        # initialize options from the settings file
        self.processing_options = read_settings('settings.txt')
        
        # user provided options
        self.data_source_identifier = id
        self.processing_options.update(opts)
        self.input = input
        self.output = output
        self.basename = os.path.basename(input)
        if self.basename.endswith('.xml'):
            self.basename = self.basename[0:-4]
        # change the type of some of the processing options
        _transform_values(self.processing_options)

        # to be filled in by document model and later processing
        self.document_model = None
        self.processing_parameters = None
        self.metadata = None
        self.xml_document = None
        self.document = None

        # directories and files, user has no control over where
        # intermediate files go
        self.DIR_GUTIME = TTK_ROOT + os.sep + 'gutime'
        self.DIR_DATA = TTK_ROOT + os.sep + 'data'
        self.DIR_DATA_TMP = self.DIR_DATA + os.sep + 'tmp'
        self.FILE_PRE = self.DIR_DATA_TMP + os.sep + self.basename + '.pre.xml'
        self.FILE_GUT = self.DIR_DATA_TMP + os.sep + self.basename + '.gut.xml'
        self.FILE_EVI = self.DIR_DATA_TMP + os.sep + self.basename + '.evi.xml'
        self.FILE_SLI = self.DIR_DATA_TMP + os.sep + self.basename + '.sli.xml'
        self.FILE_S2T = self.DIR_DATA_TMP + os.sep + self.basename + '.s2t.xml'
        self.FILE_BLI = self.DIR_DATA_TMP + os.sep + self.basename + '.bli.xml'
        self.FILE_CLA = self.DIR_DATA_TMP + os.sep + self.basename + '.cla.xml'
        self.FILE_MER = self.DIR_DATA_TMP + os.sep + self.basename + '.mer.xml'
Beispiel #3
0
 def __init__(self, options):
     """Initialize options from the settings file and the opts parameter.
     Loop through the options dictionary and replace some of the strings with
     other objects: replace 'True' with True, 'False' with False, and strings
     indicating an integer with that integer."""
     self._options = read_settings(SETTINGS)
     for (option, value) in options:
         self._options[option[2:]] = value
     for (attr, value) in self._options.items():
         if value in ('True', 'False') or value.isdigit():
             self._options[attr] = eval(value)
     self.genre = self.getopt('genre')
     self.source = self.getopt('source')
     self.platform = self.getopt('platform')
     self.pipeline = self.getopt('pipeline')
     self.loglevel = self.getopt('loglevel')
     self.trap_errors = self.getopt('trap-errors', True)
     self.extension = self.getopt('extension', '')
     self.perl = self.getopt('perl', 'perl')
     self.mallet = self.getopt('mallet')
     self.treetagger = self.getopt('treetagger')
     self.classifier = self.getopt('classifier')
     self.ee_model = self.getopt('ee-model')
     self.et_model = self.getopt('et-model')
Beispiel #4
0
 def __init__(self, options):
     """Initialize options from the settings file and the opts parameter.
     Loop through the options dictionary and replace some of the strings with
     other objects: replace 'True' with True, 'False' with False, and strings
     indicating an integer with that integer."""
     self._options = read_settings(SETTINGS)
     for (option, value) in options:
         self._options[option[2:]] = value
     for (attr, value) in self._options.items():
         if value in ('True', 'False') or value.isdigit():
             self._options[attr] = eval(value)
     self.genre = self.getopt('genre')
     self.source = self.getopt('source')
     self.platform = self.getopt('platform')
     self.pipeline = self.getopt('pipeline')
     self.loglevel = self.getopt('loglevel')
     self.trap_errors = self.getopt('trap-errors', True)
     self.extension = self.getopt('extension', '')
     self.perl = self.getopt('perl', 'perl')
     self.mallet = self.getopt('mallet')
     self.treetagger = self.getopt('treetagger')
     self.classifier = self.getopt('classifier')
     self.ee_model = self.getopt('ee-model')
     self.et_model = self.getopt('et-model')
Beispiel #5
0
    if len(sys.argv) < 2:
        sys.exit("\nMissing platform flag\nUsage: %s\n" % USAGE)

    args = sys.argv[1:]
    platform_flag = args.pop(0)
    try:
        (platform, ostype) = map(string.strip, platform_flag.split('='))
    except ValueError:
        sys.exit("\nUnexpected argument\nUsage: %s\n" % USAGE)
    if (platform != 'platform'):
        sys.exit("\nIllegal first flag.\nUsage: %s\n" % USAGE)
    if ostype in ('osx', 'linux'):
        setup_classifier(ostype)
    else:
        sys.exit("\nUnsupported os type\nUsage: %s\n" % USAGE)

    print "Updating settings.txt"
    flags = {}
    for arg in args:
        try:
            (flag, value) = map(string.strip, arg.split('='))
            flags[flag] = value
        except ValueError:
            sys.exit("\nUnexpected argument.\nUsage: %s\n" % USAGE)

    settings = read_settings('settings.txt')
    add_perl_path(settings)
    settings.update(flags)
    write_settings(settings, 'settings.txt')