Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.4k
Update CNAME#68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
adityakrmishra wants to merge1 commit intoflypythoncom:masterChoose a base branch fromadityakrmishra:patch-2
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Update CNAME#68
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
130 changes: 129 additions & 1 deletionCNAME
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,129 @@ | ||
python.flypython.com | ||
import os | ||
import sys | ||
from collections import Counter | ||
def count_words(file_path): | ||
try: | ||
with open(file_path, 'r') as file: | ||
text = file.read() | ||
words = text.split() | ||
word_counts = Counter(words) | ||
return word_counts | ||
except FileNotFoundError: | ||
print(f"File not found: {file_path}") | ||
return None | ||
def print_word_counts(word_counts): | ||
for word, count in word_counts.items(): | ||
print(f"{word}: {count}") | ||
def save_word_counts(word_counts, output_file): | ||
with open(output_file, 'w') as file: | ||
for word, count in word_counts.items(): | ||
file.write(f"{word}: {count}\n") | ||
print(f"Word counts saved to {output_file}") | ||
def main(): | ||
if len(sys.argv) < 3: | ||
print("Usage: python word_frequency_counter.py <file_path> <output_file>") | ||
return | ||
file_path = sys.argv[1] | ||
output_file = sys.argv[2] | ||
word_counts = count_words(file_path) | ||
if word_counts: | ||
print_word_counts(word_counts) | ||
save_word_counts(word_counts, output_file) | ||
if __name__ == "__main__": | ||
main() | ||
python.flypython.com | ||
import os | ||
import sys | ||
from collections import Counter | ||
import matplotlib.pyplot as plt | ||
def count_words(file_path): | ||
try: | ||
with open(file_path, 'r') as file: | ||
text = file.read() | ||
words = text.split() | ||
word_counts = Counter(words) | ||
return word_counts | ||
except FileNotFoundError: | ||
print(f"File not found: {file_path}") | ||
return None | ||
def print_word_counts(word_counts): | ||
for word, count in word_counts.items(): | ||
print(f"{word}: {count}") | ||
def save_word_counts(word_counts, output_file): | ||
with open(output_file, 'w') as file: | ||
for word, count in word_counts.items(): | ||
file.write(f"{word}: {count}\n") | ||
print(f"Word counts saved to {output_file}") | ||
def plot_word_frequencies(word_counts): | ||
words = list(word_counts.keys()) | ||
counts = list(word_counts.values()) | ||
plt.figure(figsize=(10, 5)) | ||
plt.bar(words, counts) | ||
plt.xlabel('Words') | ||
plt.ylabel('Frequencies') | ||
plt.title('Word Frequency Distribution') | ||
plt.xticks(rotation=90) | ||
plt.tight_layout() | ||
plt.savefig('word_frequencies.png') | ||
plt.show() | ||
print("Word frequency plot saved as 'word_frequencies.png'") | ||
def main(): | ||
if len(sys.argv) < 3: | ||
print("Usage: python word_frequency_counter.py <file_path> <output_file>") | ||
return | ||
file_path = sys.argv[1] | ||
output_file = sys.argv[2] | ||
word_counts = count_words(file_path) | ||
if word_counts: | ||
print_word_counts(word_counts) | ||
save_word_counts(word_counts, output_file) | ||
plot_word_frequencies(word_counts) | ||
if __name__ == "__main__": | ||
main() | ||
def summarize_word_frequencies(word_counts, top_n=10): | ||
most_common = word_counts.most_common(top_n) | ||
print(f"\nTop {top_n} most common words:") | ||
for word, count in most_common: | ||
print(f"{word}: {count}") | ||
def filter_short_words(word_counts, min_length=5): | ||
filtered_counts = {word: count for word, count in word_counts.items() if len(word) >= min_length} | ||
return filtered_counts | ||
# Extended functionalities | ||
if __name__ == "__main__": | ||
if len(sys.argv) < 3: | ||
print("Usage: python word_frequency_counter.py <file_path> <output_file>") | ||
else: | ||
file_path = sys.argv[1] | ||
output_file = sys.argv[2] | ||
word_counts = count_words(file_path) | ||
if word_counts: | ||
print_word_counts(word_counts) | ||
save_word_counts(word_counts, output_file) | ||
plot_word_frequencies(word_counts) | ||
summarize_word_frequencies(word_counts) | ||
filtered_counts = filter_short_words(word_counts) | ||
print("\nFiltered word counts (words with 5+ characters):") | ||
print_word_counts(filtered_counts) |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.