Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pacificocean1912 patch 1 #46

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data_processing_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def execute_operations(operations, dry_run=False, silent=False, log_file=None):
# Silent mode handling
if silent:
if log_file:
with open(log_file, 'a') as f:
with open(log_file, 'a', encoding="utf-8") as f:
f.write(message + '\n')
else:
print(message)
print(message)
10 changes: 8 additions & 2 deletions image_data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def process_single_image(image_path, image_inference, text_inference, silent=Fal
message = f"File: {image_path}\nTime taken: {time_taken:.2f} seconds\nDescription: {description}\nFolder name: {foldername}\nGenerated filename: {filename}\n"
if silent:
if log_file:
with open(log_file, 'a') as f:
with open(log_file, 'a', encoding='utf-8') as f:
f.write(message + '\n')
else:
print(message)
Expand Down Expand Up @@ -145,7 +145,13 @@ def clean_ai_output(text, max_words):
# Split concatenated words (e.g., 'GoogleChrome' -> 'Google Chrome')
text = re.sub(r'([a-z])([A-Z])', r'\1 \2', text)
# Tokenize and lemmatize words
words = word_tokenize(text)
try:
words = word_tokenize(text)
except LookupError:
print(f"Error tokenizing text: {text}")
import nltk
nltk.download()
words = word_tokenize(text)
words = [word.lower() for word in words if word.isalpha()]
words = [lemmatizer.lemmatize(word) for word in words]
# Remove unwanted words and duplicates
Expand Down