1f) Percent Difficult Words Using dale_chall_words, define a function percent_difficult_words that given a text input will calculate the percent difficult words, using the following approach: Return the percent of words in a given text input that are not in dale_chall_words['easy_words']. Note that a "word" is defined by being separated from other text by a space.
1f) Percent Difficult Words Using dale_chall_words, define a function percent_difficult_words that given a text input will calculate the percent difficult words, using the following approach: Return the percent of words in a given text input that are not in dale_chall_words['easy_words']. Note that a "word" is defined by being separated from other text by a space.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Using Python
![1f) Percent Difficult Words
Using dale_chall_words, define a function percent_difficult_words that given a text input will calculate the percent
difficult words, using the following approach: Return the percent of words in a given text input that are not in
dale_chall_words['easy_words'].
Note that a "word" is defined by being separated from other text by a space.
I # YOUR CODE HERE
def percent_difficult_words(dale_chall_file):
text_input
text_input_words = text_input.split()
difficult_words_count = 0
input ("Please Enter a text : ")
for i in text_input_words:
if i not in dale_chall_file:
difficult_words_count += 1
return difficult_words_count / len(text_input_words)
* 100
final_percent_difficult_words
print("Difficult words percentage is :
= percent_difficult_words(dale_chall_file)
,final_percent_difficult_words, "%")
Please Enter a text : there are only easy words here
Difficult words percentage is :
100.0 %
1g) Calculate Percent Difficult words
Apply the above method to 'message' column of news_df , creating a new column in news_df called 'PDW' . This
column should store the percent difficult words of each message.
I # YOUR CODE HERE
I assert news_df['PDW']. max()
assert news_df['PDW'].min()
== 1.0
== 0
assert round(news_df['PDW'].mean(), 2)
== 0.48
I # Look at output
news_df.head()](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3200e892-7b83-4670-8aa5-c4c84f2a6adb%2Ffb13df6a-5b9b-430f-9f01-0d6a5c60aacf%2Fgo3wvvl_processed.png&w=3840&q=75)
Transcribed Image Text:1f) Percent Difficult Words
Using dale_chall_words, define a function percent_difficult_words that given a text input will calculate the percent
difficult words, using the following approach: Return the percent of words in a given text input that are not in
dale_chall_words['easy_words'].
Note that a "word" is defined by being separated from other text by a space.
I # YOUR CODE HERE
def percent_difficult_words(dale_chall_file):
text_input
text_input_words = text_input.split()
difficult_words_count = 0
input ("Please Enter a text : ")
for i in text_input_words:
if i not in dale_chall_file:
difficult_words_count += 1
return difficult_words_count / len(text_input_words)
* 100
final_percent_difficult_words
print("Difficult words percentage is :
= percent_difficult_words(dale_chall_file)
,final_percent_difficult_words, "%")
Please Enter a text : there are only easy words here
Difficult words percentage is :
100.0 %
1g) Calculate Percent Difficult words
Apply the above method to 'message' column of news_df , creating a new column in news_df called 'PDW' . This
column should store the percent difficult words of each message.
I # YOUR CODE HERE
I assert news_df['PDW']. max()
assert news_df['PDW'].min()
== 1.0
== 0
assert round(news_df['PDW'].mean(), 2)
== 0.48
I # Look at output
news_df.head()
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education