Skip to content

Commit

Permalink
Created Indico base class, and abstracted text extractor logic
Browse files Browse the repository at this point in the history
  • Loading branch information
adelavega committed Mar 7, 2017
1 parent 2b31f50 commit 63ffd6d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pliers/extractors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
''' Extractor hierarchy. '''

from .base import ExtractorResult, merge_results
from .api import IndicoAPIExtractor, ClarifaiAPIExtractor
from .api import IndicoAPITextExtractor, ClarifaiAPIExtractor
from .audio import STFTAudioExtractor, MeanAmplitudeExtractor
from .google import (GoogleVisionAPIFaceExtractor,
GoogleVisionAPILabelExtractor,
Expand Down
19 changes: 18 additions & 1 deletion pliers/extractors/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

class IndicoAPIExtractor(Extractor):

''' Uses the Indico API to extract sentiment of text.
''' Base class for all Indico API Extractors
Args:
api_key (str): A valid API key for the Indico API. Only needs to be
passed the first time the extractor is initialized.
Expand Down Expand Up @@ -61,6 +62,22 @@ def __init__(self, api_key=None, models=None):
"personality, personas, text_features.")
raise ValueError(msg)

class IndicoAPITextExtractor(IndicoAPIExtractor):

''' Base class for all Indico API Extractors that work on text, such as
sentiment extraction.
Args:
api_key (str): A valid API key for the Indico API. Only needs to be
passed the first time the extractor is initialized.
models (list): The names of the Indico models to use.
'''

_optional_input_type = (TextStim, ComplexTextStim)

def __init__(self, api_key=None, models=None):
super(IndicoAPITextExtractor, self).__init__()

def _extract(self, stim):

if isinstance(stim, TextStim):
Expand Down

0 comments on commit 63ffd6d

Please sign in to comment.