अपने पैकेज में और फ़ंक्शनैलिटी जोड़ना
पिछले काम की बदौलत, आपके पास पहले से ही अपने Python पैकेज का एक कंकाल (skeleton) तैयार है. इस अभ्यास में, आप शब्द-उपयोग की टेक्स्ट एनालिसिस के लिए ज़रूरी फंक्शन्स परिभाषित करेंगे.
फ़ाइल counter_utils.py में, आप अपने पैकेज का हिस्सा बनने के लिए 2 फंक्शन लिखेंगे: plot_counter और sum_counters. आपके पैकेज की संरचना नीचे दिए गए ट्री में दिख रही है. इस अभ्यास के कोडिंग हिस्सों के लिए, आप counter_utils.py फ़ाइल में ही काम करेंगे.
text_analyzer
├── __init__.py
└── counter_utils.py
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Software Engineering Principles
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import needed functionality
from collections import Counter
def plot_counter(counter, n_most_common=5):
# Subset the n_most_common items from the input counter
top_items = ____.most_common(____)
# Plot `top_items`
plot_counter_most_common(top_items)