nlp_architect.models.absa.inference package

Submodules

nlp_architect.models.absa.inference.data_types module

class nlp_architect.models.absa.inference.data_types.LexiconElement(term: list, score: str = None, polarity: str = None, is_acquired: str = None, position: str = None)[source]

Bases: object

class nlp_architect.models.absa.inference.data_types.Polarity[source]

Bases: enum.Enum

An enumeration.

NEG = 'NEG'
POS = 'POS'
UNK = 'UNK'
class nlp_architect.models.absa.inference.data_types.SentimentDoc(doc_text: str = None, sentences: list = None)[source]

Bases: object

static decoder(obj)[source]
Parameters:obj – object to be decoded
Returns:decoded Sentence object
doc_text
json()[source]

Return json representations of the object

Returns:json representations of the object
Return type:json
pretty_json()[source]

Return pretty json representations of the object

Returns:pretty json representations of the object
Return type:json
sentences
class nlp_architect.models.absa.inference.data_types.SentimentDocEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(o)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class nlp_architect.models.absa.inference.data_types.SentimentSentence(start: int, end: int, events: list)[source]

Bases: object

end
events
start
class nlp_architect.models.absa.inference.data_types.Term(text: str, kind: nlp_architect.models.absa.inference.data_types.TermType, polarity: nlp_architect.models.absa.inference.data_types.Polarity, score: float, start: int, length: int)[source]

Bases: object

len
polarity
score
start
text
type
class nlp_architect.models.absa.inference.data_types.TermType[source]

Bases: enum.Enum

An enumeration.

ASPECT = 'AS'
INTENSIFIER = 'INT'
NEGATION = 'NEG'
OPINION = 'OP'

nlp_architect.models.absa.inference.inference module

class nlp_architect.models.absa.inference.inference.SentimentInference(aspect_lex: Union[str, os.PathLike], opinion_lex: Union[str, os.PathLike, dict], parse: bool = True, parser='spacy', spacy_model='en_core_web_sm')[source]

Bases: object

Main class for sentiment inference execution.

opinion_lex

Opinion lexicon as outputted by TrainSentiment module.

aspect_lex

Aspect lexicon as outputted by TrainSentiment module.

intensifier_lex

Pre-defined intensifier lexicon.

Type:dict
negation_lex

Pre-defined negation lexicon.

Type:dict
parse_data(data: os.PathLike, out_dir: Union[str, os.PathLike])[source]
run(doc: str = None, parsed_doc: nlp_architect.common.core_nlp_doc.CoreNLPDoc = None) → nlp_architect.models.absa.inference.data_types.SentimentDoc[source]

Run SentimentInference on a single document.

Returns:The sentiment annotated document, which contains the detected events per sentence.
run_multiple(data: Union[str, os.PathLike] = None, parsed_data: Union[str, os.PathLike] = None, out_dir: Union[str, os.PathLike] = PosixPath('/home/runner/nlp-architect/cache/absa/inference'))[source]

Module contents