Skip to content

Commit

Permalink
make string matching more lenient
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshit Hajela committed Apr 28, 2021
1 parent d2c328f commit b32e3da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
26 changes: 13 additions & 13 deletions backend/companies.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"MMM": "3M Company",
"MMM": "3M",
"AXP": "American Express",
"AMGN": "Amgen",
"AAPL": "Apple Inc.",
"AAPL": "Apple",
"BA": "Boeing",
"CAT": "Caterpillar Inc.",
"CVX": "Chevron Corporation",
"CSCO": "Cisco Systems",
"KO": "The Coca-Cola Company",
"DOW": "Dow Inc.",
"CAT": "Caterpillar",
"CVX": "Chevron",
"CSCO": "Cisco",
"KO": "Coca-Cola",
"DOW": "Dow",
"GS": "Goldman Sachs",
"HD": "The Home Depot",
"HD": "Home Depot",
"HON": "Honeywell",
"IBM": "IBM",
"INTC": "Intel",
"JNJ": "Johnson & Johnson",
"JPM": "JPMorgan Chase",
"JPM": "JPMorgan",
"MCD": "McDonald's",
"MRK": "Merck & Co.",
"MRK": "Merck",
"MSFT": "Microsoft",
"NKE": "Nike",
"PG": "Procter & Gamble",
"CRM": "Salesforce",
"TRV": "The Travelers Companies",
"UNH": "UnitedHealth Group",
"UNH": "UnitedHealth",
"VZ": "Verizon",
"V": "Visa Inc.",
"V": "Visa",
"WBA": "Walgreens Boots Alliance",
"WMT": "Walmart",
"DIS": "The Walt Disney Company"
"DIS": "Walt Disney"
}
7 changes: 6 additions & 1 deletion backend/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ def join(self):

def fetchComments(self):
for comment in self.sr_obj.stream.comments(skip_existing=True, pause_after=5):
comment_text = comment.body.casefold()
for ticker in self.companies:
if ticker in comment.body or self.companies[ticker] in comment.body:
casefolded_company = self.companies[ticker].casefold()
if ('{0} '.format(ticker) in comment.body or
' {0}'.format(ticker) in comment.body or
'{0} '.format(casefolded_company) in comment_text or
' {0}'.format(casefolded_company) in comment_text):
comment_obj = { "ticker": ticker, "text": comment.body, "timestamp": math.ceil(time.time_ns()/1000000) }
self.output(comment_obj)
break
Expand Down

0 comments on commit b32e3da

Please sign in to comment.