diff options
author | Cody Hiar <cody@hiar.ca> | 2021-10-25 14:34:37 -0600 |
---|---|---|
committer | Cody Hiar <cody@hiar.ca> | 2021-10-25 14:34:37 -0600 |
commit | e3d2ffca585660f0c088ab8323bfe78a86ba75e3 (patch) | |
tree | 1f542c4d1c032cdc85149ccfd28cafc402ddb3d0 /wordcount/multilang/resources/sentencespout.py | |
parent | 08cf73a70e3ce2dbc85e8b389f15090c148ec003 (diff) |
Save working version of deploying jars
Diffstat (limited to 'wordcount/multilang/resources/sentencespout.py')
-rw-r--r-- | wordcount/multilang/resources/sentencespout.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/wordcount/multilang/resources/sentencespout.py b/wordcount/multilang/resources/sentencespout.py new file mode 100644 index 0000000..a75f37d --- /dev/null +++ b/wordcount/multilang/resources/sentencespout.py @@ -0,0 +1,28 @@ +import storm +import random +# Define some sentences +SENTENCES = """ +the cow jumped over the moon +an apple a day keeps the doctor away +four score and seven years ago +snow white and the seven dwarfs +i am at two with nature +""".strip().split('\n') + +class SentenceSpout(storm.Spout): + # Not much to do here for such a basic spout + def initialize(self, conf, context): + self._conf = conf + self._context = context + + storm.logInfo("Spout instance starting...") + + # Process the next tuple + def nextTuple(self): + # Emit a random sentence + sentence = random.choice(SENTENCES) + storm.logInfo("Emiting %s" % sentence) + storm.emit([sentence]) + +# Start the spout when it's invoked +SentenceSpout().run() |