I've installed weka python wrapper on Windows 7. And I tried running the sample code:
import weka.core.jvm as jvm
jvm.start()
data_dir = "E:/Files/Fourth/"
from weka.core.converters import Loader
loader = Loader("weka.core.converters.TextDirectoryLoader")
datasets = [
data_dir + "File 1",
data_dir + "File 2",
data_dir + "File 3",
data_dir + "File 4",
data_dir + "File 5"
]
data = loader.load_file(datasets)
data.delete_last_attribute()
print(data)
and I receive the following error:
Traceback (most recent call last):
File "C:/Python27/weekaa.py", line 16, in <module>
data = loader.load_file(datasets)
File "C:\Python27\lib\site-packages\weka\core\converters.py", line 67,
in load_file
self.enforce_type(self.jobject,
"weka.core.converters.FileSourcedConverter")
File "C:\Python27\lib\site-packages\weka\core\classes.py", line 155,
in enforce_type
raise TypeError("Object does not implement or subclass " +
intf_or_class + "!")
TypeError: Object does not implement or
subclass weka.core.converters.FileSourcedConverter!
I tried solution in previous asked question by adding class path to weka.jar or python-weka-wrapper but didn't work. The error doesn't appear when loading .arff file type.
Is there a solution to load text files?
Note: each file in dataset has set of text document files(for later clustering)