Skip to content

Instantly share code, notes, and snippets.

Avatar

SemantiveCode

View GitHub Profile
View gensim_summarization.py
import nltk
import gensim
text = requests.get('http://rare-technologies.com/the_matrix_synopsis.txt').text
gensim_summary = gensim.summarization.summarize(text)
View centroid_word_embedding_summarization.py
"""
First install text_summarizer using
pip install git+https://github.com/lambdaofgod/text-summarizer
"""
import nltk
import text_summarizer
# prepare nltk data
nltk.download('punkt')
@SemantiveCode
SemantiveCode / send_failure.py
Created Oct 31, 2018
Async Execution - send failure
View send_failure.py
def handler(event, context):
  task_token = event['task_token']
  error_info = event['error_info']
  states_client.send_task_failure(
      taskToken=task_token,
      error=error_info['Error'],
      cause=error_info.get('Cause', 'Cause is undefined.'),
  )
@SemantiveCode
SemantiveCode / send_success.py
Created Oct 31, 2018
Async Execution - send success
View send_success.py
def handler(event, context):
  task_token = event['task_token']
  output_state = event['state'][0]
  states_client.send_task_success(
      taskToken=task_token,
      output=json.dumps(output_state),
  )
  return event
@SemantiveCode
SemantiveCode / async_invoke.py
Created Oct 31, 2018
Start asynchronous action Lambda
View async_invoke.py
def async_invoke_handler(event, context):
   activity_task_response = states_client.get_activity_task(
       activityArn=ASYNC_ACTION_ACTIVITY_ARN,
       workerName=context.function_name,
   )
   if 'taskToken' not in activity_task_response:
       raise MissingScheduledActivityTaskException()
   input_for_nested_execution = {
You can’t perform that action at this time.