Closed Aron9080 closed 6 years ago
Seems you are using tensorflow as backend. You should use Keras 1.2.1 with Theano 0.9.0 as backend
@ruidan Thank you so much! It works very well, but I confuse that if I want to get the target(s) of a sentence by the user's input with this model, e.g "The sushi was lousy - too sweet or too salty and the portions tiny", which method is to extract the terms of "sushi" and "portions", and to classify them to the categories of "Food"? I spent some time on studying code but I haven't found the answer. The deadline of my projecy is coming, so I will be in debt to you if you can help you
This current code does not provide specific api for that directly. But you can easily implement it by yourself:
1) For a given new text, you need to first preprocess it the same way as the code does on the training and test sentences. (This step is very important).
2) The model will assign an inferred aspect label to the input sentence. Since the model training is completely unsupervised, the inferred aspects are represented as ranked word lists. You need to to manually map each inferred cluster to a gold category label to get the prediction of the gold label. Please refer to evaluation.py, where you can find how the model assigns an gold label to each test sentence. Of course, you can develop some other methods to automatically map inferred aspects to gold aspects without human interruption.
3) The model is not designed to extract aspect terms/targets. You can still use it for that purpose if you want a simple unsupervised method. One possible way is to use the learned attention weights as scores, where higher score indicates higher probability to be an aspect term. For each sentence, you can set a threshold value according to the sentence length to select the possible aspect terms. The model can learn very reasonable attention weights even in an unsupervised setting. To see the quality of the learned attention weights, you can simply run the evaluation scripts on the pre-trained restaurant model to generate the attention weights on all test sentences (refer to Evaluation in README). Since the method is unsupervised, you should not expect the performance in aspect term extraction as good as other supervised methods.
@ruidan Thanks for your detailed explanation, I have implemented it.
@ruidan I downloaded this code and seem that the code does not work. The error message:
Please help!