File size: 1,341 Bytes
763746b
 
 
 
 
 
 
 
45b71d5
 
763746b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45b71d5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
from transformers import pipeline

# Function to enhance title using Hugging Face model
def generate_title_with_huggingface(description):
    result = generator(description, max_length=100, num_return_sequences=1)
    return result[0]['generated_text']

# Load the CSV file directly (replace 'input.csv' with your actual file path)
file_name = 'input.csv'  # Update this with the correct path to your CSV file
df = pd.read_csv(file_name)

# Initialize the text generation model (e.g., GPT-2)
generator = pipeline('text-generation', model='gpt-2')

# Apply the function to generate SEO-friendly titles
df['Title'] = df['Description'].apply(generate_title_with_huggingface)

# Function to generate keywords (basic example)
def generate_keywords(description):
    words = set(description.replace(',', '').replace('.', '').split())
    return ",".join(list(words)[:50])

# Generate basic keywords from the description (you can enhance this further)
df['Keywords'] = df['Description'].apply(generate_keywords)

# Save the SEO-optimized DataFrame to a new CSV file
seo_output_file_path = 'seo_huggingface_filename_title_keywords.csv'
df[['Filename', 'Title', 'Keywords']].to_csv(seo_output_file_path, index=False)

# The output file will be saved in the current working directory
print(f"File saved as {seo_output_file_path}")