You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2017/10/23 21:26:34 UTC
[kibble-scanners] branch master updated: refactor logic
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble-scanners.git
The following commit(s) were added to refs/heads/master by this push:
new c8bab42 refactor logic
c8bab42 is described below
commit c8bab4259fa0c068aded54330006433e67218462
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Oct 23 23:26:19 2017 +0200
refactor logic
- we want to stop after 50 emails
- we don't want robits
- emails already analysed count towards the 50!
---
src/plugins/scanners/ponymail-tone.py | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/plugins/scanners/ponymail-tone.py b/src/plugins/scanners/ponymail-tone.py
index 919fc76..69f7623 100644
--- a/src/plugins/scanners/ponymail-tone.py
+++ b/src/plugins/scanners/ponymail-tone.py
@@ -91,21 +91,22 @@ def scan(KibbleBit, source):
ec = 0
for hit in res['hits']['hits']:
eml = hit['_source']
- if 'mood' not in eml and not re.search(ROBITS, eml['sender']):
+ if not re.search(ROBITS, eml['sender']):
ec += 1
if ec > MAX_COUNT:
break
- emlurl = "%s/api/email.lua?id=%s" % (rootURL, eml['id'])
- KibbleBit.pprint("Fetching %s" % emlurl)
- rv = requests.get(emlurl).json()
- body = rv['body']
- KibbleBit.pprint("analyzing email")
- mood = plugins.utils.tone.getTone(KibbleBit, body)
- eml['mood'] = mood
- hm = [0,'unknown']
- for m, s in mood.items():
- if s > hm[0]:
- hm = [s,m]
- print("Likeliest overall mood: %s" % hm[1])
- KibbleBit.index('email', hit['_id'], eml)
+ if 'mood' not in eml:
+ emlurl = "%s/api/email.lua?id=%s" % (rootURL, eml['id'])
+ KibbleBit.pprint("Fetching %s" % emlurl)
+ rv = requests.get(emlurl).json()
+ body = rv['body']
+ KibbleBit.pprint("analyzing email")
+ mood = plugins.utils.tone.getTone(KibbleBit, body)
+ eml['mood'] = mood
+ hm = [0,'unknown']
+ for m, s in mood.items():
+ if s > hm[0]:
+ hm = [s,m]
+ print("Likeliest overall mood: %s" % hm[1])
+ KibbleBit.index('email', hit['_id'], eml)
KibbleBit.pprint("Done with tone analysis")
--
To stop receiving notification emails like this one, please contact
['"commits@kibble.apache.org" <co...@kibble.apache.org>'].