Package: textblob-de
German language support forTextBlobby Steven Loria.This python package is being developed as aTextBlobLanguage Extension.
SeeExtension Guidelinesfor details.FeaturesNEW:Works with Python3.7All directly accessibletextblob_declasses (e.g.Sentence()orWord()) are initialized with default models for GermanProperties or methods that do not yet work for German raise aNotImplementedErrorGerman sentence boundary detection and tokenization (NLTKPunktTokenizer)Consistent use of specified tokenizer for all tools (NLTKPunktTokenizerorPatternTokenizer)Part-of-speech tagging (PatternTagger) with keywordinclude_punc=True(defaults toFalse)Tagset conversion inPatternTaggerwith keywordtagset='penn'|'universal'|'stts'(defaults topenn)Parsing (PatternParser) with allpatternkeywords, pluspprint=True(defaults toFalse)Noun Phrase Extraction (PatternParserNPExtractor)Lemmatization (PatternParserLemmatizer)Polarity detection (PatternAnalyzer) - StillEXPERIMENTAL, does not yet have information on subjectivityFullpattern.text.deAPI support on Python3Supports Python 2 and 3Seeworking features overviewfor detailsInstalling/Upgrading$ pip install -U textblob-de
$ python -m textblob.download_corporaOr the latest development release (apparently this does not always work on Windows seeissues #1744/5for details):$ pip install -U git+https://github.com/markuskiller/textblob-de.git@dev
$ python -m textblob.download_corporaNoteTextBlobwill be installed/upgraded automatically when runningpip install. The second line (python-mtextblob.download_corpora)
downloads/updates nltk corpora and language models used inTextBlob.Usage>>>fromtextblob_deimportTextBlobDEasTextBlob>>>text='''Heute ist der 3. Mai 2014 und Dr. Meier feiert seinen 43. Geburtstag.
Ich muss unbedingt daran denken, Mehl, usw. für einen Kuchen einzukaufen. Aber leider
habe ich nur noch EUR 3.50 in meiner Brieftasche.'''>>>blob=TextBlob(text)>>>blob.sentences[Sentence("Heute ist der 3. Mai 2014 und Dr. Meier feiert seinen 43. Geburtstag."),Sentence("Ich muss unbedingt daran denken, Mehl, usw. für einen Kuchen einzukaufen."),Sentence("Aber leider habe ich nur noch EUR 3.50 in meiner Brieftasche.")]>>>blob.tokensWordList(['Heute','ist','der','3.','Mai',...]>>>blob.tags[('Heute','RB'),('ist','VB'),('der','DT'),('3.','LS'),('Mai','NN'),('2014','CD'),...]# Default: Only noun_phrases that consist of two or more meaningful parts are displayed.# Not perfect, but a start (relies heavily on parser accuracy)>>>blob.noun_phrasesWordList(['Mai 2014','Dr. Meier','seinen 43. Geburtstag','Kuchen einzukaufen','meiner Brieftasche'])>>>blob=TextBlob("Das Auto ist sehr schön.")>>>blob.parse()'Das/DT/B-NP/O Auto/NN/I-NP/O ist/VB/B-VP/O sehr/RB/B-ADJP/O schön/JJ/I-ADJP/O'>>>fromtextblob_deimportPatternParser>>>blob=TextBlobDE("Das ist ein schönes Auto.",parser=PatternParser(pprint=True,lemmata=True))>>>blob.parse()WORDTAGCHUNKROLEIDPNPLEMMADasDT----dasistVBVP---seineinDTNP---einschönesJJNP^---schönAutoNNNP^---auto..----.>>>fromtextblob_deimportPatternTagger>>>blob=TextBlob(text,pos_tagger=PatternTagger(include_punc=True))[('Das','DT'),('Auto','NN'),('ist','VB'),('sehr','RB'),('schön','JJ'),('.','.')]>>>blob=TextBlob("Das Auto ist sehr schön.")>>>blob.sentimentSentiment(polarity=1.0,subjectivity=0.0)>>>blob=TextBlob("Das ist ein hässliches Auto.")>>>blob.sentimentSentiment(polarity=-1.0,subjectivity=0.0)WarningWORK IN PROGRESS:The German polarity lexicon contains only uninflected
forms and there are no subjectivity scores yet. As of version 0.2.3, lemmatized
word forms are submitted to thePatternAnalyzer, increasing the accuracy
of polarity values. New in version 0.2.7: return type of.sentimentis now
adapted to the mainTextBloblibrary (:rtype: namedtuple).>>>blob.words.lemmatize()WordList(['das','sein','ein','hässlich','Auto'])>>>fromtextblob_de.lemmatizersimportPatternParserLemmatizer>>>_lemmatizer=PatternParserLemmatizer()>>>_lemmatizer.lemmatize("Das ist ein hässliches Auto.")[('das','DT'),('sein','VB'),('ein','DT'),('hässlich','JJ'),('Auto','NN')]NoteMake sure that you use unicode strings on Python2 if your input contains
non-ascii characters (e.g.word = u"schön").Access topatternAPI in Python3>>>fromtextblob_de.packagesimportpattern_deaspd>>>print(pd.attributive("neugierig",gender=pd.FEMALE,role=pd.INDIRECT,article="die"))neugierigenNoteAlternatively, the path totextblob_de/extcan be added to thePYTHONPATH, which allows
the use ofpattern.dein almost the same way as described in itsDocumentation.
The only difference is that you will have to prepend an underscore:from _pattern.de import .... This is a precautionary measure in case thepatternlibrary gets native Python3 support in the future.Documentation and API Referencehttp://textblob-de.readthedocs.org/en/latestRequirementsPython >= 2.6 or >= 3.3TODOPlanned ExtensionsAdditional PoS tagging options, e.g. NLTK tagging (NLTKTagger)Improve noun phrase extraction (e.g. based onRFTaggeroutput)Improve sentiment analysis (find suitable subjectivity scores)Improve functionality ofSentence()andWord()objectsAdapt more tests from the mainTextBloblibrary (esp. forTextBlobDE()intest_blob.py)LicenseMIT licensed. See the bundledLICENSEfile for more details.ThanksCoded with Wing IDE (free open source developer license)Changelog0.4.3 (03/01/2019)Added support for Python3.7 (StopIteration-->return)Pull Request #18(thanks @andrewmfiorillo)Fixed tests for Google translation examplesUpdated tox/Travis-CI config files to include latest Python & pypy versionsUpdated sphinx_rtd_theme to version 0.4.2 to fix rendering problems onRTDUpdatedsetup.py publishcommands,Makefile&Manifest.into new PiPy (usingtwine)0.4.2 (02/05/2015)Removed dependency onNLTK,as it already is aTextBlobdependencyTemporary workaround forNLTK Issue #824for tox/Travis-CI(update 13/01/2015)NLTK Issue #824fixed, workaround removedEnabledpatterntagset conversion ('penn'|'universal'|'stts') forPatternTaggerAdded tests for tagset conversionFixed test for Arabic translation example (Google translation has changed)Added tests for lemmatizerBugfix:PatternAnalyzerno longer breaks on subsequent ocurrences of the same(word, tag)pairs on Python3 see comments toPull Request #11Bugfix/performance enhancement: Sentiment dictionary inPatternAnalyzerno longer reloaded for every sentencePull Request #11(thanks @Arttii)0.4.1 (03/10/2014)Docs hosted onRTDRemoved dependency on nltk’s depricatedPunktWordTokenizerand replaced it withTreebankWordTokenizerseenltk/nltk#746 (comment)for details0.4.0 (17/09/2014)FixedIssue #7(restoretextblob>=0.9.0compatibility)Depend onnltk3. Vendorizednltkwas removed intextblob>=0.9.0FixedImportErroron Python2 (unicodecsv)0.3.1 (29/08/2014)ImprovedPatternParserNPExtractor(less false positives in verb filter)Made sure that all keyword arguments with defaultNoneare checked withis not NoneFixed shortcut to_pattern.dein vendorized libraryAddedMakefileto facilitate development processAdded docs and API reference0.3.0 (14/08/2014)FixedIssue #5(text + space + period)0.2.9 (14/08/2014)Fixed tokenization inPatternParser(if initialized manually, punctuation was not always separated from words)Improved handling of empty strings (Issue #3) and of strings containing single punctuation marks (Issue #4) inPatternTaggerandPatternParserAdded tests for empty strings and for strings containing single punctuation marks0.2.8 (14/08/2014)FixedIssue #3(empty string)FixedIssue #4(space + punctuation)0.2.7 (13/08/2014)FixedIssue #1lemmatization of strings containing a forward slash (/)EnhancementIssue #2use the same rtype astextblobfor sentiment detection.Fixed tokenization inPatternParserLemmatizer0.2.6 (04/08/2014)FixedMANIFEST.infor package data insdist0.2.5 (04/08/2014)sdistis non-functional as important files are missing due to a misconfiguration inMANIFEST.in- does not affectwheelsMajor internal refactoring (but no backwards-incompatible API changes) with the aim of restoring complete compatibility to originalpattern>=2.6library on Python2Separation oftextblobandpatterncodeOn Python2 the vendorized version ofpattern.text.deis only used if original is not installed (same asnltk)Madepattern.de.pprintfunction and all parser keywords accessible to customise parser outputAccess to completepattern.text.deAPI on Python2 and Python3from textblob_de.packages import pattern_de as pdtoxpassed on all major platforms (Win/Linux/OSX)0.2.3 (26/07/2014)Lemmatizer:PatternParserLemmatizer()extracts lemmata from Parser outputImproved polarity analysis through look-up of lemmatised word forms0.2.2 (22/07/2014)Option: Include punctuation intags/pos_tagsproperties (b = TextBlobDE(text, tagger=PatternTagger(include_punc=True)))AddedBlobberDE()class initialized with German modelsTextBlobDE(),Sentence(),WordList()andWord()classes are now all initialized with German modelsRestored complete API compatibility withtextblob.tokenizersmodule of the mainTextBloblibrary0.2.1 (20/07/2014)Noun Phrase Extraction:PatternParserNPExtractor()extracts NPs from Parser outputRefactored the wayTextBlobDE()passes on arguments and keyword arguments to individual toolsBackwards-incompatible: Deprecateparser_show_lemmata=Truekeyword inTextBlob(). Useparser=PatternParser(lemmata=True)instead.0.2.0 (18/07/2014)vastly improved tokenization (NLTKPunktTokenizerandPatternTokenizerwith tests)consistent use of specified tokenizer for all toolsTextBlobDEwith initialized default models for GermanParsing (PatternParser) plustest_parsers.pyEXPERIMENTALimplementation of Polarity detection (PatternAnalyzer)first attempt at extracting German Polarity clues intode-sentiment.xmltox tests passing for py26, py27, py33 and py340.1.3 (09/07/2014)First release on PyPI0.1.0 - 0.1.2 (09/07/2014)First release on githubA number of experimental releases for testing purposesAdapted version badges, tests & travis-ci configCode adapted from sample extensiontextblob-frLanguage specific linguistic resources copied frompattern-de