flexmatcherを試してみる
諸々の事情でSchema Matchingの現状を調査中。あまり実装が見当たらないが、python実装の1つ、flexmatcherを試してみる。 (2017年から活動がないようなのが残念)
ドキュメントに従ってインストール
$ pip3 install flexmatcher $ pip3 list | grep flexmatcher flexmatcher (1.0.4)
ドキュメントに記載のExampleを動かしてみると、途中のtrainする部分でエラーが出た。
>>> fm.train() Training FlexMatcher ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/dist-packages/flexmatcher/flexmatcher.py", line 156, in train clf_inst.fit(self.train_data) File "/usr/local/lib/python3.6/dist-packages/flexmatcher/classify/charDistClassifier.py", line 58, in fit self.features = feat_df.ix[:, 1:].as_matrix() File "/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py", line 5141, in __getattr__ return object.__getattribute__(self, name) AttributeError: 'DataFrame' object has no attribute 'ix'
AttributeError: 'DataFrame' object has no attribute 'ix'
は、pandasのバージョンが新しい(1.0.0以上)ことが原因のようなので、ダウングレードしてみる。
参考:
- pandas で 'DataFrame' object has no attribute 'ix' が出てきたとき - Qiita
- What’s new in 1.0.0 (January 29, 2020) — pandas 1.0.0 documentation
githubの最終コミットが2017年10月あたりだったので、 pandasのRelease historyから、それより前のバージョンを探す。
2017年7月リリースの0.20.3にしてみる。
$ pip3 uninstall pandas $ pip3 install pandas==0.20.3 $ pip3 list | grep pandas pandas (0.20.3)
これでExampleを実行したらうまくいった。
>>> print(predicted_mapping['rt']) movie_rating
※ドキュメントではprint(predicted_mapping['rc'])
となっているが、'rt'
の誤りと思われる。
※ちなみにここにあるexample.pyは、flexmatcherのコンストラクタの仕様が若干違うようで、そのままだとflexmatcher 1.0.4では動かないので注意。