パッケージのクラスを使う
テキスト分析を行うために拡張していく Document クラスの基礎を作成しました。この演習では、テキストを保存する現在の機能を試してみましょう。
以下は、パッケージ開発の過程で構築したドキュメントツリーです。my_script.py で作業を進めます。
working_dir
├── text_analyzer
│ ├── __init__.py
│ ├── counter_utils.py
│ ├── document.py
└── my_script.py
この演習はコースの一部です
Python におけるソフトウェアエンジニアリングの原則
演習の手順
importパッケージをtext_analyzerします。- セッションに読み込まれている
Document変数を使って、datacamp_tweetのインスタンスを作成します。 - 新しく作成した
textインスタンスのDocument属性の内容を出力します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Import custom text_analyzer package
import ____
# Create an instance of Document with datacamp_tweet
my_document = text_analyzer.____(text=____)
# Print the text attribute of the Document instance
print(____)