Question: QUESTION: Identifying Proper Names In A Text Document text_data = Heres to the crazy ones, the misfits, the rebels, thetroublemakers, the round pegs in

QUESTION: Identifying Proper Names In A Text Document

text_data = """
Here’s to the crazy ones, the misfits, the rebels, thetroublemakers, the round pegs in the square holes. The ones who seethings differently — they’re not fond of rules. You can quote them,disagree with them, glorify or vilify them, but the only thing youcan’t do is ignore them because they change things. They push thehuman race forward, and while some may see them as the crazy ones,we see genius, because the ones who are crazy enough to think
that they can change the world, are the ones who do.
The quote baove is by Steve Jobs. Mr. Jobs also said: I choose alazy person to do a hard job. Because a lazy person will find aneasy way to do it. Steve started the apple computer company withSteve Wozniak (aka `Woz'). Little known facts:
Trump did not like Jobs. Jobs did not like Trump.
"""

Similar to the previous question ("Creating Rules ToIdentify Verbs"), write code that automatically identifies allwords/terms that are proper names. Use thesample text provided in text_data above.

Examples of proper names are:

  • John
  • Vancouver
  • Trudeau
  • Pierre Trudeau
  • British Columbia, Canada
  • Rememberance Day

import nltk

def is_word_a_pname(word):
word_is_a_pname = False
test_word = text_data.split()
if word in test_word:

rules = [(word.endswith('Jobs'))]

if all(rules):

print(True)

return word_is_a_pname

DISCUSSION

Briefly discuss the performance of your code (1-2paragraphs).

What types of proper names did the code perform well on? Whattypes of proper names did it not perform well on?

Step by Step Solution

3.54 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code performed well on proper names that were clearly defined such as Steve Jobs Steve Wozniak a... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!