Пример #1
0
    def test_register(self):
        registry = formats.get_registry()
        assert_false(CustomFormat in registry.values())

        formats.register('trt', CustomFormat)

        assert_true(CustomFormat in registry.values())
        assert_true('trt' in registry.keys())
Пример #2
0
    def test_register(self):
        registry = formats.get_registry()
        assert_false(CustomFormat in registry.values())

        formats.register('trt', CustomFormat)

        assert_true(CustomFormat in registry.values())
        assert_true('trt' in registry.keys())
Пример #3
0
 def _read_data(self, dataset, format=None):
     """Reads a data file and returns an iterable that can be used
     as testing or training data.
     """
     # Attempt to detect file format if "format" isn't specified
     if not format:
         format_class = formats.detect(dataset)
         if not format_class:
             raise FormatError("Could not automatically detect format for the given " "data source.")
     else:
         registry = formats.get_registry()
         if format not in registry.keys():
             raise ValueError("'{0}' format not supported.".format(format))
         format_class = registry[format]
     return format_class(dataset, **self.format_kwargs).to_iterable()
Пример #4
0
 def _read_data(self, dataset, format=None):
     """Reads a data file and returns an iterable that can be used
     as testing or training data.
     """
     # Attempt to detect file format if "format" isn't specified
     if not format:
         format_class = formats.detect(dataset)
         if not format_class:
             raise FormatError('Could not automatically detect format for the given '
                               'data source.')
     else:
         registry = formats.get_registry()
         if format not in registry.keys():
             raise ValueError("'{0}' format not supported.".format(format))
         format_class = registry[format]
     return format_class(dataset, **self.format_kwargs).to_iterable()
def read_data(file, format=None, **kwargs):
    """Reads a data file and returns an iterable that can be used
    as testing or training data.

    Adapted from:
    https://github.com/sloria/TextBlob/blob/dev/textblob/classifiers.py#L128
    """
    # Attempt to detect file format if "format" isn't specified
    if not format:
        format_class = formats.detect(file)
        if not format_class:
            raise FormatError('Could not automatically detect format for the '
                              'given data source.')
    else:
        registry = formats.get_registry()
        if format not in registry.keys():
            raise ValueError("'{0}' format not supported.".format(format))
        format_class = registry[format]
    return format_class(file, **kwargs).to_iterable()
def read_data(file, format=None, **kwargs):
    """Reads a data file and returns an iterable that can be used
    as testing or training data.

    Adapted from:
    https://github.com/sloria/TextBlob/blob/dev/textblob/classifiers.py#L128
    """
    # Attempt to detect file format if "format" isn't specified
    if not format:
        format_class = formats.detect(file)
        if not format_class:
            raise FormatError('Could not automatically detect format for the '
                              'given data source.')
    else:
        registry = formats.get_registry()
        if format not in registry.keys():
            raise ValueError("'{0}' format not supported.".format(format))
        format_class = registry[format]
    return format_class(file, **kwargs).to_iterable()
Пример #7
0
 def test_available(self):
     registry = formats.get_registry()
     assert_true('csv' in registry.keys())
     assert_true('json' in registry.keys())
     assert_true('tsv' in registry.keys())
Пример #8
0
 def test_available(self):
     registry = formats.get_registry()
     assert_true('csv' in registry.keys())
     assert_true('json' in registry.keys())
     assert_true('tsv' in registry.keys())