'How to extract relation between entities for stock prediction
I am trying to extract relation between two entities (entity1- relation- entity2) from news articles for stock prediction. I have used NER for entity extraction. It would be great if anyone could help me with relationship extraction.
Solution 1:[1]
Relation Extraction is a difficult task in NLP and most of the time there's not a one-size-fits-all solution to that. Depending on the task that you're trying to solve, I would suggest reading some literature about it on Google Scholar and see if there's something similar to what you're trying to do.
Sometimes, authors are kind enough to publish the code of their solution, which are mainly PyTorch/Tensorflow models (hopefully) trained on a specific dataset. One example is this paper.
If you want to stick with Spacy, there are some guides that might help you, but I'm not sure how well it could scale with the task that you need to solve.
Another more basic approach could be to just extract the shortest path between two entities in the semantic graph of a sentence. This might be quite limited, but can be fairly easy to implement.
One final idea that comes to mind is to use encoders and compute the similarity between sentences. If you're doing multi-class classification, this could help solving your problem.
Hope you find something useful among these.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Francesco |