|
import pandas as pd |
|
from transformers import pipeline |
|
from google.colab import files |
|
|
|
|
|
def generate_title_with_huggingface(description): |
|
result = generator(description, max_length=100, num_return_sequences=1) |
|
return result[0]['generated_text'] |
|
|
|
|
|
|
|
uploaded = files.upload() |
|
|
|
|
|
file_name = list(uploaded.keys())[0] |
|
|
|
|
|
df = pd.read_csv(file_name) |
|
|
|
|
|
generator = pipeline('text-generation', model='gpt-2') |
|
|
|
|
|
df['Title'] = df['Description'].apply(generate_title_with_huggingface) |
|
|
|
|
|
def generate_keywords(description): |
|
words = set(description.replace(',', '').replace('.', '').split()) |
|
return ",".join(list(words)[:50]) |
|
|
|
|
|
df['Keywords'] = df['Description'].apply(generate_keywords) |
|
|
|
|
|
seo_output_file_path = 'seo_huggingface_filename_title_keywords.csv' |
|
df[['Filename', 'Title', 'Keywords']].to_csv(seo_output_file_path, index=False) |
|
|
|
|
|
files.download(seo_output_file_path) |
|
|