dli-invest / reccomendation-engine

stock recommendation engine based on all my stonk data.
Apache License 2.0
1 stars 1 forks source link

Holmes to parse headlines for recommendation engine #4

Open FriendlyUser opened 2 years ago

FriendlyUser commented 2 years ago
# Setup
import holmes_extractor as holmes
ontology = holmes.Ontology("holmes_test.owl")
manager = holmes.Manager("en_core_web_trf", ontology=ontology, number_of_workers=1)

# Register search phrase
manager.register_search_phrase("An ENTITYORG takes over an ENTITYORG")

# Parse documents
manager.parse_and_register_document("Royal Bank of Scotland announces it intends to acquire Brewin Dolphin", "1")
manager.parse_and_register_document("Chipmaker MaxLinear Inc announced on Thursday it will buy Silicon Motion Technology Corp for nearly $4 billion.", "2")
manager.parse_and_register_document("Last month, cybersecurity company Mandiant was purchased by Alphabet", "3")
manager.parse_and_register_document("The Datto takeover by Kaseya", "4")

# Perform matching
matches = manager.match()

# Check all documents matched
print(len(matches))
# -> 4

# Extract companies doing the taking over
print([match['word_matches'][0]['document_phrase'] for match in matches])
# -> ['Royal Bank', 'Chipmaker MaxLinear Inc', 'Alphabet', 'Kaseya']

# Extract companies being taken over
print([match['word_matches'][2]['document_phrase'] for match in matches])
# -> ['Brewin Dolphin', 'Silicon Motion Technology Corp', 'cybersecurity company Mandiant', 'Datto']

Update the engine to use holmes to track dates and accquistions.