Skip to content

Commit b32e3da

Browse files
committed
make string matching more lenient
1 parent d2c328f commit b32e3da

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

backend/companies.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"MMM": "3M Company",
2+
"MMM": "3M",
33
"AXP": "American Express",
44
"AMGN": "Amgen",
5-
"AAPL": "Apple Inc.",
5+
"AAPL": "Apple",
66
"BA": "Boeing",
7-
"CAT": "Caterpillar Inc.",
8-
"CVX": "Chevron Corporation",
9-
"CSCO": "Cisco Systems",
10-
"KO": "The Coca-Cola Company",
11-
"DOW": "Dow Inc.",
7+
"CAT": "Caterpillar",
8+
"CVX": "Chevron",
9+
"CSCO": "Cisco",
10+
"KO": "Coca-Cola",
11+
"DOW": "Dow",
1212
"GS": "Goldman Sachs",
13-
"HD": "The Home Depot",
13+
"HD": "Home Depot",
1414
"HON": "Honeywell",
1515
"IBM": "IBM",
1616
"INTC": "Intel",
1717
"JNJ": "Johnson & Johnson",
18-
"JPM": "JPMorgan Chase",
18+
"JPM": "JPMorgan",
1919
"MCD": "McDonald's",
20-
"MRK": "Merck & Co.",
20+
"MRK": "Merck",
2121
"MSFT": "Microsoft",
2222
"NKE": "Nike",
2323
"PG": "Procter & Gamble",
2424
"CRM": "Salesforce",
2525
"TRV": "The Travelers Companies",
26-
"UNH": "UnitedHealth Group",
26+
"UNH": "UnitedHealth",
2727
"VZ": "Verizon",
28-
"V": "Visa Inc.",
28+
"V": "Visa",
2929
"WBA": "Walgreens Boots Alliance",
3030
"WMT": "Walmart",
31-
"DIS": "The Walt Disney Company"
31+
"DIS": "Walt Disney"
3232
}

backend/updater.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ def join(self):
4040

4141
def fetchComments(self):
4242
for comment in self.sr_obj.stream.comments(skip_existing=True, pause_after=5):
43+
comment_text = comment.body.casefold()
4344
for ticker in self.companies:
44-
if ticker in comment.body or self.companies[ticker] in comment.body:
45+
casefolded_company = self.companies[ticker].casefold()
46+
if ('{0} '.format(ticker) in comment.body or
47+
' {0}'.format(ticker) in comment.body or
48+
'{0} '.format(casefolded_company) in comment_text or
49+
' {0}'.format(casefolded_company) in comment_text):
4550
comment_obj = { "ticker": ticker, "text": comment.body, "timestamp": math.ceil(time.time_ns()/1000000) }
4651
self.output(comment_obj)
4752
break

0 commit comments

Comments
 (0)