Python Forum
IPython Notebook - How to use a class you have written
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IPython Notebook - How to use a class you have written
#1
Good evening,

I have completed my first code in Ipython Notebook (as MSword file), and now I need to use the class that I wrote the code for to answer 10 questions at the bottom of the notebook that I have attached.

This is a Text Analyzer. I am supposed to use the code written in the Text Analyzer class and answer the questions. However, I can't find any written help on how to use the class to answer these questions.Can someone please help me understand how this works?

Thank you.

Attached Files

.docx   Analyzing Text Checker.docx (Size: 96.56 KB / Downloads: 436)
Reply
#2
(Mar-22-2019, 12:41 AM)moga2003 Wrote: I have completed my first code in Ipython Notebook (as MSword file)
Notebook has it own format .ipynb which can eg be shared with nbviewer,MSword should no be used to share Notebooks.
Quote:I can't find any written help on how to use the class to answer these questions.Can someone please help me understand how this works?
To help you get started.
The class is written so it can take in url or text(.txt) files.
They have written in internal parsing in class,eg tag_id is own name they made up.
If parsing straight for BS it had look like this us of id not tag_id:
id_tag = soup.find('div', id='content-main')
id_tag.text
Using class for question 1.
>>> url = 'https://www.webucator.com/how-to/william-henry-harrisons-inaugural-address.cfm'
>>> ta = TextAnalyzer(url)
>>> ta.set_content_to_tag('div', tag_id='content-main')
>>> print("word_count", ta.word_count)
word_count 8430
Reply
#3
Thank you so much snippsat!!! I would never have figured this out.

And, I will remember nbviewer for future posts

I only have 2 questions left that are stumping me.

Question #2: least common letter. My code accounts for most common word, but it does not break it down into individual characters(letters). How do I change it from most common word, into least common letter?

Question #8: Palindromes. How do I use this code to find palindromes? I've checked and tried a few different ways, but they don't work for this, and honestly, I have never written anything to find a palindrome. From what I have researched, the only thing I have understood is that I am supposed to use this [::-1] in the code.

Any thoughts, or help?

As always, your help is definitely appreciated.

Thank you.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020