The
1.settings_file argument to the Static{Dedupe,RecordLink,Gazetteer} constructors,
training_file argument to the prepare_training() methods
file_obj argument to the write_training() and write_settings() methods,
are all expected to be TextIO or BinaryIO objects. Could we expand the API to accept file paths? It would make calling code simpler by avoiding the with open(...) as f: ... boiler plate. I don't see where it would lead to any ambiguity. And it looks like due to the nice architecture using abstract base classes, it wouldn't be a large maintenance burden either (from a quick browse it looks like there would only need to be a change in a single place for each of these methods, and even then each of them could use a single _open_path_like() util method)
The one thing I'm not sure about is the logic for selecting what a "path-like" is. Maybe isinstance(str) or isinstance(path.Path)? Or just try to open() them and see if that succeeds?
I'd be happy to write a PR if this looks like an idea worth pursuing. Thanks for the library!
The 1.
settings_file
argument to the Static{Dedupe,RecordLink,Gazetteer} constructors,training_file
argument to theprepare_training()
methodsfile_obj
argument to thewrite_training()
andwrite_settings()
methods,are all expected to be
TextIO
orBinaryIO
objects. Could we expand the API to accept file paths? It would make calling code simpler by avoiding thewith open(...) as f: ...
boiler plate. I don't see where it would lead to any ambiguity. And it looks like due to the nice architecture using abstract base classes, it wouldn't be a large maintenance burden either (from a quick browse it looks like there would only need to be a change in a single place for each of these methods, and even then each of them could use a single_open_path_like()
util method)The one thing I'm not sure about is the logic for selecting what a "path-like" is. Maybe
isinstance(str)
orisinstance(path.Path)
? Or justtry
toopen()
them and see if that succeeds?I'd be happy to write a PR if this looks like an idea worth pursuing. Thanks for the library!