unicode-org / lstm_word_segmentation

Python code for training an LSTM model for word segmentation in Thai, Burmese, and similar languages.
Other
19 stars 8 forks source link

file path issue #7

Open FrankYFTang opened 3 years ago

FrankYFTang commented 3 years ago

Test code

from lstm_word_segmentation.word_segmenter import pick_lstm_model
   word_segmenter = pick_lstm_model(model_name="Thai_codepoints_exclusive_model4_heavy",
                                    embedding="codepoints",
                                    train_data="exclusive BEST",
                                    eval_data="exclusive BEST")

Traceback (most recent call last): File "test_file.py", line 42, in main(sys.argv[1:]) File "test_file.py", line 31, in main word_segmenter = pick_lstm_model(model_name="Thai_codepoints_exclusive_model4_heavy", File "/usr/local/google/home/ftang/lstm_word_segmentation/lstm_word_segmentation/word_segmenter.py", line 655, in pick_lstm_model model = keras.models.load_model(file) File "/usr/local/google/home/ftang/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/save.py", line 181, in load_model isinstance(filepath, h5py.File) or h5py.is_hdf5(filepath))): File "/usr/local/google/home/ftang/.local/lib/python3.8/site-packages/h5py/_hl/base.py", line 41, in is_hdf5 fname = os.path.abspath(fspath(fname)) TypeError: expected str, bytes or os.PathLike object, not PosixPath

Looks like we need to wrap the file with str()

SahandFarhoodi commented 3 years ago

On my MacBook, this works with or without str. I think PosixPath is only compatible with Unix and some other platforms. If this is true then yes, we need that str around the file name. Are you running this code on Windows?