module_dependenciesΒΆ

The module_dependencies Python module can be used to determine which sections of some arbitrary Python module are most frequently used, allowing you to prioritise your development efforts appropriately. For example:

>>> from module_dependencies import Module
>>> module = Module("nltk", count=1000)
>>> module.plot()
nltktokenizecorpusdownloadstemtagtranslatedataprobabilitytreeclassifyutilmetricssentimentchunkCFGgrammartextsemcollocations__version__twitterRegexpParserclusterparseChartParserConditionalFreqDistTextCollectiondrawhelpclean_htmldownloaderflattenlmRegexpTaggerRecursiveDescentParsercasual_tokenizeraise_errorMaxentClassifiereverygramsWhitespaceTokenizerwsdmodelfeatstructMLEProbDistFeatureChartParserBigramCollocationFinderChunkParserIDecisionTreeClassifierConditionalProbDisttrigramsLidstoneProbDistProductionword_tokenizesent_tokenizeRegexpTokenizerTweetTokenizertreebankregexpwordpunct_tokenizepunkttoktokregexp_tokenizeutilapimosesMWETokenizersexprstanfordwordTabTokenizerWhitespaceTokenizerblankline_tokenizestopwordswordnetbrowngutenbergtwitter_samplesreutersmovie_reviewswordssentiwordnettreebankreaderwebtextcmudictptbnamessubjectivityinauguralwordnet_icutilnps_chatconll2000europarl_rawporterwordnetsnowballlancasterisriSnowballStemmerRegexpStemmerpos_tagStanfordNERTaggerperceptronBigramTaggerUnigramTaggerutilTrigramTaggerstanfordStanfordPOSTaggerapi_pos_tagbleu_scoreAlignedSentIBMModel1meteormeteor_scorechrf_scoregleu_scorepathloadfindZipFilePathPointerFreqDistELEProbDistMLEProbDistConditionalFreqDistTreebracket_parsenaivebayesutilaccuracyscikitlearnmaxentPositiveNaiveBayesClassifierdecisiontreeNaiveBayesClassifierngramsbigramsskipgramsingramsdistancescoresBigramAssocMeasuresagreementinterval_distanceTrigramAssocMeasuresassociationaccuracyvaderutilSentimentAnalyzerne_chunktree2conlltagsregexputilRegexpParserfromstringNonterminalnonterminalsis_terminalCFGis_nonterminalread_grammarProductionFeatureGrammarstandard_nonterm_parserTextlogicBigramAssocMeasuresTrigramCollocationFinderTrigramAssocMeasuresAbstractCollocationFinderBigramCollocationFindercommonTweetWriterTweetViewerQueryStreamerTwittercredsfromfileutileuclidean_distanceKMeansClustererDependencyGraphstanfordgenerateCoreNLPParserBottomUpChartParserTreeWidgetutilupenn_tagsetloadDownloaderbuild_indexMLELidstonetrainleskNgramModelFeaturefrom_wordstrainTreebankWordTokenizerTreebankWordDetokenizerWordPunctTokenizerPunktSentenceTokenizerPunktLanguageVarsPunktTrainerToktokTokenizeralign_tokensstring_span_tokenizeTokenizerIMosesTokenizersexpr_tokenizeStanfordTokenizerwordsfileidssentsrawextendreadmesynsetssynsetNOUNADJADVVERBlemmaall_synsetswordsmorphywup_similaritylemmassynset_from_pos_and_offsetADJ_SATall_lemma_nameslangspath_similarity_synset_from_pos_and_offsetget_versionsentstagged_sentswordsfileidstagged_wordsappendcategorieswordsfileidssentsrawparasreadmeopenstringsabspathtokenizedfileidsfileidswordscategoriesrawsentsreadmewordsfileidsrawwordsreadmefileidssenti_synsetsgetsynsetloadtagged_sentsparsed_sentsfileidstagged_wordssentswordnetapiBracketParseCorpusReaderSynsetbracket_parsefileidsrawsentswordsdictentriesparsed_sentsfileidswordsfileidsreadmesentsfileidscategorieswordsfileidsrawicLazyCorpusLoaderwordschunked_sentsgermanPorterStemmerWordNetLemmatizerSnowballStemmerEnglishStemmerLancasterStemmerISRIStemmerlanguagesPerceptronTaggeruntagStanfordPOSTaggerStanfordNERTaggerTaggerIcorpus_bleusentence_bleuSmoothingFunctionclosest_ref_lengthbrevity_penaltymodified_precisionsingle_meteor_scoresentence_chrfcorpus_gleuappendfromstringrootNaiveBayesClassifierapply_featuresaccuracySklearnClassifierMaxentClassifierDecisionTreeClassifieredit_distancejaccard_distancemasi_distanceprecisionf_measurerecallchi_sqpmiAnnotationTaskchi_sqBigramAssocMeasuresSentimentIntensityAnalyzerextract_unigram_featsmark_negationRegexpParserconlltags2treefromstringANY_TYPEComplexTypeTRUTH_TYPEBasicTypeEntityTypeApplicationExpressionConstantExpressionVariableLogicParserfrom_wordsfrom_documents__init__from_wordsfrom_documentsjson2csvjson2csv_entitiescosine_distanceStanfordParsergenerateCanvasFrame

Beyond simply plotting this data, it can also be returned in machine-readable formats. See the general Module documentation for more information.


Alternatively, module_dependencies allows for determining the dependencies or imports of a given Python file, for example:

from module_dependencies import Source
from pprint import pprint

# This creates a Source instance for this file itself
src = Source.from_file(__file__)

pprint(src.dependencies())
pprint(src.imports())

This program outputs:

['module_dependencies.Source.from_file', 'pprint.pprint']
['module_dependencies', 'pprint']

See the general Source documentation for more information.

Furthermore, the general API Reference documentation has more examples and details on module_dependencies.