ó <¿CVc@@sdZddlmZmZddlZddlZddlmZddlZddl m Z m Z ddl m Z mZddlmZmZddlmZmZdd lmZmZdd lmZmZmZmZmZdd l m!Z!dd l"m#Z#dd l$m%Z%m&Z&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ej0j1Z2d„Z3defd„ƒYZ4de5fd„ƒYZ6e7d„Z8d„Z9deefd„ƒYZ:de:fd„ƒYZ;de:fd„ƒYZ<de=fd „ƒYZ>dS(!uWrappers for various units of text, including the main :class:`TextBlob `, :class:`Word `, and :class:`WordList ` classes. Example usage: :: >>> from textblob import TextBlob >>> b = TextBlob("Simple is better than complex.") >>> b.tags [(u'Simple', u'NN'), (u'is', u'VBZ'), (u'better', u'JJR'), (u'than', u'IN'), (u'complex', u'NN')] >>> b.noun_phrases WordList([u'simple']) >>> b.words WordList([u'Simple', u'is', u'better', u'than', u'complex']) >>> b.sentiment (0.06666666666666667, 0.41904761904761906) >>> b.words[0].synsets()[0] Synset('simple.n.01') .. versionchanged:: 0.8.0 These classes are now imported from ``textblob`` rather than ``text.blob``. i(tunicode_literalstabsolute_importN(t defaultdict(tcached_propertytrequires_nltk_corpus(t lowerstriptPUNCTUATION_REGEX(t singularizet pluralize(tBlobComparableMixintStringlikeMixin(tunicodet basestring(tBaseNPExtractort BaseTaggert BaseTokenizertBaseSentimentAnalyzert BaseParser(tFastNPExtractor(t NLTKTagger(t WordTokenizert sent_tokenizet word_tokenize(tPatternAnalyzer(t PatternParser(t Translator(tsuggestcC@sP|dkrtjS|dkr&tjS|dkr9tjS|dkrLtjSdS(u.Converts a Penn corpus tag into a Wordnet tag.uNNuNNSuNNPuNNPSuJJuJJRuJJSuVBuVBDuVBGuVBNuVBPuVBZuRBuRBRuRBS(uNNuNNSuNNPuNNPS(uJJuJJRuJJS(uVBuVBDuVBGuVBNuVBPuVBZ(uRBuRBRuRBSN(t_wordnettNOUNtADJtVERBtADVtNone(ttag((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt_penn_to_wordnet1s    tWordcB@sÚeZdZeƒZdd„Zdd„Zd„Zd„Z d„Z d„Z ddd„Z d „Z d „Zd „Zeed „ƒƒZedd „ƒZed„ƒZed„ƒZdd„Zdd„ZRS(umA simple word representation. Includes methods for inflection, translation, and WordNet integration. cC@stt|ƒj||ƒS(u¦Return a new instance of the class. It is necessary to override this method in order to handle the extra pos_tag argument in the constructor. (tsuperR#t__new__(tclststringtpos_tag((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR%EscC@s||_||_dS(N(R'R((tselfR'R(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt__init__Ls cC@s t|jƒS(N(treprR'(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt__repr__PscC@s|jS(N(R'(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt__str__SscC@stt|jƒƒS(u4Return the singular version of the word as a string.(R#t _singularizeR'(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRVscC@stt|jƒƒS(u2Return the plural version of the word as a string.(R#t _pluralizeR'(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRZsuencC@sC|dkr$|jj|jƒ}n|jj|jd|d|ƒS(uvTranslate the word to another language using Google's Translate API. .. versionadded:: 0.5.0 t from_langtto_langN(R t translatortdetectR't translate(R)R0tto((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR4^s cC@s|jj|jƒS(ubDetect the word's language using Google's Translate API. .. versionadded:: 0.5.0 (R2R3R'(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytdetect_languageiscC@s t|jƒS(uReturn a list of (word, confidence) tuples of spelling corrections. Based on: Peter Norvig, "How to Write a Spelling Corrector" (http://norvig.com/spell-correct.html) as implemented in the pattern library. .. versionadded:: 0.6.0 (RR'(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt spellcheckps cC@st|jƒddƒS(užCorrect the spelling of the word. Returns the word with the highest confidence using the spelling corrector. .. versionadded:: 0.6.0 i(R#R7(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytcorrect{scC@s4|jdk rt|jƒnd}|jd|ƒS(uGReturn the lemma of this word using Wordnet's morphy function. tposN(R(R R"t lemmatize(R)R!((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytlemmaƒs$cC@s:|dkrtj}ntjjƒ}|j|j|ƒS(uÐReturn the lemma for a word using WordNet's morphy function. :param pos: Part of speech to filter upon. If `None`, defaults to ``_wordnet.NOUN``. .. versionadded:: 0.8.1 N(R RRtnltktstemtWordNetLemmatizerR:R'(R)R9t lemmatizer((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR:‹s  cC@s|jddƒS(utThe list of Synset objects for this Word. :rtype: list of Synsets .. versionadded:: 0.7.0 R9N(t get_synsetsR (R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytsynsets™scC@s|jddƒS(u�The list of definitions for this word. Each definition corresponds to a synset. .. versionadded:: 0.7.0 R9N(tdefineR (R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt definitions£scC@stj|j|ƒS(uReturn a list of Synset objects for this word. :param pos: A part-of-speech tag to filter upon. If ``None``, all synsets for all parts of speech will be loaded. :rtype: list of Synsets .. versionadded:: 0.7.0 (RRAR'(R)R9((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR@¬s cC@s)g|jd|ƒD]}|jƒ^qS(u;Return a list of definitions for this word. Each definition corresponds to a synset for this word. :param pos: A part-of-speech tag to filter upon. If ``None``, definitions for all parts of speech will be loaded. :rtype: List of strings .. versionadded:: 0.7.0 R9(R@t definition(R)R9tsyn((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRB¸s N(t__name__t __module__t__doc__RR2R R%R*R,R-RRR4R6R7R8RRR;R:RARCR@RB(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR#=s(            tWordListcB@s�eZdZd„Zd„Zd„Zd„Zd„Zd„Ze d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„ZRS(u A list-like collection of words.cC@s?g|D]}t|ƒ^q|_tt|ƒj|jƒdS(u[Initialize a WordList. Takes a collection of strings as its only argument. N(R#t _collectionR$RIR*(R)t collectiontw((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR*Ès"cC@s t|jƒS(N(tstrRJ(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR-ÏscC@s+|jj}djd|dt|jƒƒS(u.Returns a string representation for debugging.u {cls}({lst})R&tlst(t __class__RFtformatR+RJ(R)t class_name((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR,Òs cC@s2t|tƒr#|j|j|ƒS|j|SdS(u$Returns a string at the given index.N(t isinstancetsliceRORJ(R)tkey((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt __getitem__×scC@s|j|j||!ƒS(N(RORJ(R)titj((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt __getslice__ÞscC@s t|jƒS(N(titerRJ(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt__iter__âscO@sN|s8g|D]}|jƒ^q j|jƒ||ŽS|jj|||ŽS(uÆGet the count of a word or phrase `s` within this WordList. :param strg: The string to count. :param case_sensitive: A boolean, whether or not the search is case-sensitive. (tlowertcountRJ(R)tstrgtcase_sensitivetargstkwargstword((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR\ås+cC@s9t|tƒr%|jjt|ƒƒS|jj|ƒSdS(ukAppend an object to end. If the object is a string, appends a :class:`Word ` object. N(RRR RJtappendR#(R)tobj((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRbðscC@sBg|D]3}|jjt|tƒr1t|ƒn|ƒ^q|S(u‹Extend WordList by appending elements from ``iterable``. If an element is a string, appends a :class:`Word ` object. (RJRbRRR R#(R)titerablete((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytextendùs;cC@s&|jg|D]}|jƒ^q ƒS(u1Return a new WordList with each word upper-cased.(ROtupper(R)Ra((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRgscC@s&|jg|D]}|jƒ^q ƒS(u1Return a new WordList with each word lower-cased.(ROR[(R)Ra((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR[scC@s&|jg|D]}|jƒ^q ƒS(u8Return the single version of each word in this WordList.(ROR(R)Ra((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR scC@s&|jg|D]}|jƒ^q ƒS(u8Return the plural version of each word in this WordList.(ROR(R)Ra((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR scC@s&|jg|D]}|jƒ^q ƒS(u/Return the lemma of each word in this WordList.(ROR:(R)Ra((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR:s(RFRGRHR*R-R,RURXRZtFalseR\RbRfRgR[RRR:(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRIÅs           cC@s\|r |n|j}|dk rRt||ƒ rRtdjd|d|ƒƒ‚n|p[|S(ujValidates a parameter passed to __init__. Makes sure that obj is the correct class. Return obj if it's not None or falls back to default :param obj: The object passed in. :param name: The name of the parameter. :param base_class: The class that obj must inherit from. :param default: The default object to fall back upon if obj is None. u#{name} must be an instance of {cls}tnameR&N(RFR RRt ValueErrorRP(RcRit base_classtdefaulttbase_class_name((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt_validated_params  c C@sµt|ddttjjjfdtjddƒ|_t|ddtdtj ƒ|_ t|dt tj ƒ|_ t|dt tj ƒ|_ t|d ttjƒ|_||_d S( u;Common initialization between BaseBlob and Blobber classes.u tokenizerRkRlRmu BaseTokenizeru np_extractoru pos_taggeruanalyzeruparserN(RnRR<ttokenizetapit TokenizerItBaseBlobt tokenizerR t np_extractorRt pos_taggerRtanalyzerRtparsert classifier(RcRsRuRtRvRwRx((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt_initialize_models&s      RrcB@sseZdZeƒZeƒZeƒZe ƒZ e ƒZ e ƒZdddddded„Zed„ƒZed„ƒZdd„Zdd„Zd„Zed„ƒZed„ƒZed „ƒZed „ƒZed „ƒZeZed „ƒZed „ƒZdd„Z ddd„Z!d„Z"d„Z#d„Z$d„Z%d„Z&d„Z'de(j)d„Z*RS(uZAn abstract base class that all textblob classes will inherit from. Includes words, POS tag, NP, and word count properties. Also includes basic dunder and string methods for making objects like Python strings. :param text: A string. :param tokenizer: (optional) A tokenizer instance. If ``None``, defaults to :class:`WordTokenizer() `. :param np_extractor: (optional) An NPExtractor instance. If ``None``, defaults to :class:`FastNPExtractor() `. :param pos_tagger: (optional) A Tagger instance. If ``None``, defaults to :class:`NLTKTagger `. :param analyzer: (optional) A sentiment analyzer. If ``None``, defaults to :class:`PatternAnalyzer `. :param parser: A parser. If ``None``, defaults to :class:`PatternParser `. :param classifier: A classifier. .. versionchanged:: 0.6.0 ``clean_html`` parameter deprecated, as it was in NLTK. c C@sŠt|tƒs-tdjt|ƒƒƒ‚n|rBtdƒ‚n||_|_t|jdt ƒ|_ t |||||||ƒdS(NuHThe `text` argument passed to `__init__(text)` must be a string, not {0}u^clean_html has been deprecated. To remove HTML markup, use BeautifulSoup's get_text() functiontall( RRR t TypeErrorRPttypetNotImplementedErrortrawR'RtTruetstrippedRy( R)ttextRsRuRtRvRwRxt clean_html((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR*Us cC@stt|jdtƒƒS(uíReturn a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList ` of word tokens. t include_punc(RIRR~Rh(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytwordsdscC@st|jj|jƒƒS(u–Return a list of tokens, using this blob's tokenizer object (defaults to :class:`WordTokenizer `). (RIRsRoR~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyttokensnscC@s1|dk r|n|j}t|j|jƒƒS(u°Return a list of tokens, using ``tokenizer``. :param tokenizer: (optional) A tokenizer object. If None, defaults to this blob's default tokenizer. N(R RsRIRoR~(R)Rstt((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRouscC@s+|dk r|n|j}|j|jƒS(u°Parse the text. :param parser: (optional) A parser instance. If ``None``, defaults to this blob's default parser. .. versionadded:: 0.6.0 N(R RwtparseR~(R)Rwtp((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR‡~scC@s1|jdkrtdƒ‚n|jj|jƒS(u2Classify the blob using the blob's ``classifier``.u-This blob has no classifier. Train one first!N(RxR t NameErrortclassifyR~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRЉscC@s|jj|jƒS(uFReturn a tuple of form (polarity, subjectivity ) where polarity is a float within the range [-1.0, 1.0] and subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: namedtuple of the form ``Sentiment(polarity, subjectivity)`` (RvtanalyzeR~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt sentiment�s cC@stƒj|jƒdS(uaReturn the polarity score as a float within the range [-1.0, 1.0] :rtype: float i(RR‹R~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytpolarityšscC@stƒj|jƒdS(u¤Return the subjectivity score as a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: float i(RR‹R~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt subjectivity¢scC@sJtg|jj|jƒD]*}t|ƒdkr|jƒjƒ^qƒS(u-Returns a list of noun phrases for this blob.i(RIRttextractR~tlentstripR[(R)tphrase((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt noun_phrases«scC@sYg|jj|jƒD]?\}}tjt|ƒƒst|d|ƒt|ƒf^qS(uReturns an list of tuples of the form (word, POS tag). Example: :: [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] :rtype: list of tuples R((RuR!R~RtmatchR R#(R)RaR†((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytpos_tags²s cC@sSttƒ}g|jD]}t|ƒ^q}x|D]}||cd7` ii(trangeR�R„RI(R)tnRVtgrams((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytngrams×s  AuencC@sL|dkr$|jj|jƒ}n|j|jj|jd|d|ƒƒS(u½Translate the blob to another language. Uses the Google Translate API. Returns a new TextBlob. Requires an internet connection. Usage: :: >>> b = TextBlob("Simple is better than complex") >>> b.translate(to="es") TextBlob('Lo simple es mejor que complejo') Language code reference: https://developers.google.com/translate/v2/using_rest#language-params .. versionadded:: 0.5.0. :param str from_lang: Language to translate from. If ``None``, will attempt to detect the language. :param str to: Language to translate to. :rtype: :class:`BaseBlob ` R0R1N(R R2R3R'ROR4R~(R)R0R5((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR4ãs cC@s|jj|jƒS(u‘Detect the blob's language using the Google Translate API. Requires an internet connection. Usage: :: >>> b = TextBlob("bonjour") >>> b.detect_language() u'fr' Language code reference: https://developers.google.com/translate/v2/using_rest#language-params .. versionadded:: 0.5.0 :rtype: str (R2R3R~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR6ÿscC@sDtjj|jdƒ}d„|Dƒ}dj|ƒ}|j|ƒS(u‚Attempt to correct the spelling of a blob. .. versionadded:: 0.6.0 :rtype: :class:`BaseBlob ` u\w+|[^\w\s]|\scs@s!|]}t|ƒjƒVqdS(N(R#R8(t.0RL((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pys su(R<Rotregexp_tokenizeR~tjoinRO(R)R…t correctedtret((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR8scC@s|jS(uXKey used by ComparableMixin to implement all rich comparison operators. (R~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt_cmpkey!scC@s|jS(u8Key used by StringlikeMixin to implement string methods.(R~(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt_strkey'scC@st|jƒƒS(N(thashR¤(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt__hash__+scC@sht|tƒr#|j|j|ƒSt|tƒrI|j|j|jƒStdj|jjƒƒ‚dS(u�Concatenates two text objects the same way Python strings are concatenated. Arguments: - `other`: a string or a text object u.Operands must be either strings or {0} objectsN(RRR ROR~RrR{RPRF(R)tother((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt__add__.s  cC@st|jƒj||ƒƒS(uBehaves like the built-in str.split() except returns a WordList. :rtype: :class:`WordList ` (RIR¥tsplit(R)tseptmaxsplit((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRª=sN(+RFRGRHRRtRRuRRsRR2RRvRRwR RhR*RR„R…RoR‡RŠRŒR�RŽR“R•ttagsR™RšRžR4R6R8R¤R¥R§R©tsystmaxsizeRª(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRr9s@                   tTextBlobcB@skeZdZed„ƒZed„ƒZed„ƒZed„ƒZd„Z ed„ƒZ d„Z RS(u?A general text block, meant for larger bodies of text (esp. those containing sentences). Inherits from :class:`BaseBlob `. :param str text: A string. :param tokenizer: (optional) A tokenizer instance. If ``None``, defaults to :class:`WordTokenizer() `. :param np_extractor: (optional) An NPExtractor instance. If ``None``, defaults to :class:`FastNPExtractor() `. :param pos_tagger: (optional) A Tagger instance. If ``None``, defaults to :class:`NLTKTagger `. :param analyzer: (optional) A sentiment analyzer. If ``None``, defaults to :class:`PatternAnalyzer `. :param classifier: (optional) A classifier. cC@s |jƒS(u4Return list of :class:`Sentence ` objects.(t_create_sentence_objects(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt sentencesVscC@stt|jdtƒƒS(uíReturn a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList ` of word tokens. Rƒ(RIRR~Rh(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR„[scC@sg|jD]}|j^q S(u/List of strings, the raw sentences in the blob.(R²R~(R)tsentence((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt raw_sentencesescC@sg|jD]}|j^q S(u6Returns a list of each sentence's dict representation.(R²tdict(R)R³((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt serializedjscO@stj|j||ŽS(uŠReturn a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 (tjsontdumpsR¶(R)R_R`((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pytto_jsonoscC@s |jƒS(uÞThe json representation of this blob. .. versionchanged:: 0.5.1 Made ``json`` a property instead of a method to restore backwards compatibility that was broken after version 0.4.0. (R¹(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR·wscC@sÀg}t|jƒ}d}xž|D]–}|jj||ƒ}|t|ƒ7}|t|ƒ}t|d|d|d|jd|jd|jd|jd|j d |j ƒ}|j |ƒq"W|S( u>Returns a list of Sentence objects from the raw text. it start_indext end_indexRsRtRuRvRwRx( RR~tindexR�tSentenceRsRtRuRvRwRxRb(R)tsentence_objectsR²t char_indextsentRºR»ts((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR±�s ( RFRGRHRR²R„tpropertyR´R¶R¹R·R±(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR°Fs   R½cB@s,eZdZddd„Zed„ƒZRS(uÃA sentence within a TextBlob. Inherits from :class:`BaseBlob `. :param sentence: A string, the raw sentence. :param start_index: An int, the index where this sentence begins in a TextBlob. If not given, defaults to 0. :param end_index: An int, the index where this sentence ends in a TextBlob. If not given, defaults to the length of the sentence - 1. icO@sPtt|ƒj|||Ž||_|_|p?t|ƒd|_|_dS(Ni(R$R½R*tstartRºR�tendR»(R)R³RºR»R_R`((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR*¡scC@sJi|jd6|jd6|jd6|jd6|jd6|jd6|jd6S(u)The dict representation of this sentence.urawu start_indexu end_indexustrippedu noun_phrasesupolarityu subjectivity(R~RºR»R€R“R�RŽ(R)((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRµ¨s      N(RFRGRHR R*RÂRµ(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR½–s tBlobbercB@sneZdZeƒZeƒZeƒZe ƒZ e ƒZ ddddddd„Zd„Zd„ZeZRS(u:A factory for TextBlobs that all share the same tagger, tokenizer, parser, classifier, and np_extractor. Usage: >>> from textblob import Blobber >>> from textblob.taggers import NLTKTagger >>> from textblob.tokenizers import SentenceTokenizer >>> tb = Blobber(pos_tagger=NLTKTagger(), tokenizer=SentenceTokenizer()) >>> blob1 = tb("This is one blob.") >>> blob2 = tb("This blob has the same tagger and tokenizer.") >>> blob1.pos_tagger is blob2.pos_tagger True :param tokenizer: (optional) A tokenizer instance. If ``None``, defaults to :class:`WordTokenizer() `. :param np_extractor: (optional) An NPExtractor instance. If ``None``, defaults to :class:`FastNPExtractor() `. :param pos_tagger: (optional) A Tagger instance. If ``None``, defaults to :class:`NLTKTagger `. :param analyzer: (optional) A sentiment analyzer. If ``None``, defaults to :class:`PatternAnalyzer `. :param parser: A parser. If ``None``, defaults to :class:`PatternParser `. :param classifier: A classifier. .. versionadded:: 0.4.0 cC@s t|||||||ƒdS(N(Ry(R)RsRuRtRvRwRx((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR*ÚscC@s@t|d|jd|jd|jd|jd|jd|jƒS(uËReturn a new TextBlob object with this Blobber's ``np_extractor``, ``pos_tagger``, ``tokenizer``, ``analyzer``, and ``classifier``. :returns: A new :class:`TextBlob `. RsRuRtRvRwRx(R°RsRuRtRvRwRx(R)R�((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyt__call__ßs cC@sk|jr|jjjdnd}dj|jjj|jjj|jjj|jjj|jjj|ƒS(Nu()uNoneulBlobber(tokenizer={0}(), pos_tagger={1}(), np_extractor={2}(), analyzer={3}(), parser={4}(), classifier={5})( RxRORFRPRsRuRtRvRw(R)tclassifier_name((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyR,ês"     N(RFRGRHRRtRRuRRsRRvRRwR R*RÆR,R-(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyRŶs       (?RHt __future__RRR®R·t collectionsRR<ttextblob.decoratorsRRttextblob.utilsRRttextblob.inflectRR.RR/ttextblob.mixinsR R ttextblob.compatR R t textblob.baseR RRRRttextblob.np_extractorsRttextblob.taggersRttextblob.tokenizersRRRttextblob.sentimentsRttextblob.parsersRttextblob.translateRt textblob.enRtcorpustwordnetRR"R#tlistRIR RnRyRrR°R½tobjectRÅ(((sc/private/var/folders/cc/xm4nqn811x9b50x1q_zpkmvdjlphkp/T/pip-build-FUwmDn/textblob/textblob/blob.pyts:   (  ˆQ  ÿP