Skip to content

Commit

Permalink
code refactoring (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmhard authored Aug 12, 2024
1 parent 0744caf commit 1b9de37
Show file tree
Hide file tree
Showing 20 changed files with 571 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## one of analysis dashboard

![Image](./image.png)
![Image](./assets/image.png)

### libraries used
- bs4
Expand Down
File renamed without changes
6 changes: 3 additions & 3 deletions clean_stop_words.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json

data_file_path = 'cleared_unwanted_keys.json'
keys_to_remove_file_path = 'stop_words.json'
output_file_path = 'final_filtered_data.json'
data_file_path = 'outputs/cleared_unwanted_keys.json'
keys_to_remove_file_path = 'outputs/stop_words.json'
output_file_path = 'outputs/final_filtered_data.json'

with open(data_file_path, 'r', encoding='utf-8') as file:
key_value_pairs = json.load(file)
Expand Down
6 changes: 3 additions & 3 deletions clear-non-alpha.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import re

file_path = 'word_dictionary.json'
file_path = 'outputs/word_dictionary.json'

valid_keys_file = 'valid_keys.json'
invalid_keys_file = 'invalid_keys.json'
valid_keys_file = 'outputs/valid_keys.json'
invalid_keys_file = 'outputs/invalid_keys.json'

with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions process.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <top_n>"
exit 1
fi

top_n="$1"

python_files=(
# "words-extractor.py"
# "clear-non-alpha.py"
# "separate.py"
# "remove_unwanted_chars_from_keys.py"
"clean_stop_words.py"
)

for file in "${python_files[@]}"
do
echo "Running $file..."
python "$file"
if [ $? -ne 0 ]; then
echo "Error: $file failed to run."
exit 1
fi
echo "$file completed successfully."
done

echo "Running TOP $top_n..."
python "top-words.py" $top_n
if [ $? -ne 0 ]; then
echo "Error: $last_file failed to run."
exit 1
fi

echo "All Processing is done executed."
4 changes: 2 additions & 2 deletions remove-duplicates.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json

# Path to the input JSON file containing an array of words
input_file_path = 'stop_words.json'
input_file_path = 'outputs/stop_words.json'

# Path to the output JSON file where unique words will be saved
output_file_path = 'unique_words.json'
output_file_path = 'outputs/unique_words.json'

# Open and load the JSON file
with open(input_file_path, 'r', encoding='utf-8') as file:
Expand Down
4 changes: 2 additions & 2 deletions remove_unwanted_chars_from_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import re

# Path to the input JSON file with key-value pairs
input_file_path = 'non_english_keys.json'
input_file_path = 'outputs/non_english_keys.json'

# Path to the output JSON file where filtered key-value pairs will be saved
output_file_path = 'cleared_unwanted_keys.json'
output_file_path = 'outputs/cleared_unwanted_keys.json'

# Regular expressions for identifying unwanted characters in keys
symbols_pattern = re.compile(r'[^\w\s]', re.UNICODE) # Matches any symbols (excluding alphanumeric and whitespace)
Expand Down
6 changes: 3 additions & 3 deletions separate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
import re

file_path = 'valid_keys.json'
file_path = 'outputs/valid_keys.json'

# Output file paths
english_keys_file = 'english_keys.json'
non_english_keys_file = 'non_english_keys.json'
english_keys_file = 'outputs/english_keys.json'
non_english_keys_file = 'outputs/non_english_keys.json'

# Open and load the JSON file
with open(file_path, 'r', encoding='utf-8') as file:
Expand Down
Loading

0 comments on commit 1b9de37

Please sign in to comment.