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
icon
Related questions
Question

Using Python, create a Percent Difficult Words column using the method above

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()
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Basic sql queries
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
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education