Перейти к содержимому

Использование ChatGpt для статей

В тексте много технических терминов, требуется понимание работы технологических инструментов.

Не вдаваясь в подробности, ИИ “понимает”, какой ответ предпочтительнее для какого вопроса, то есть качество ответа зависит полностью от правильности формулировки ответа.

ChatGPT

Я хочу переработать данную информацию в формат статьи в стиле Википедии, используя синтаксис DocuWiki:

Текст статьи-оригинала

Выгрузка и анализ телеграм-каналов и групп

Заголовок раздела «Выгрузка и анализ телеграм-каналов и групп»
1. Выгрузить историю чата/канала

 

2. Преобразовать файл в текстовый

Скопируйте данный файл в папку с экспортированными сообщениями:

import argparse
from bs4 import BeautifulSoup
import os
def parse_html_file(html_file):
# Open and read the HTML file
with open(html_file, 'r', encoding='utf-8') as f:
html_content = f.read()
# Parse the HTML content using BeautifulSoup
soup = BeautifulSoup(html_content, 'html.parser')
# List to store the parsed messages
messages = []
# Loop through each message in the history
for message_div in soup.find_all('div', class_='message default clearfix'):
# Extract the datetime from the 'title' attribute in the 'details' div
date_div = message_div.find('div', class_='pull_right date details')
if date_div and 'title' in date_div.attrs:
datetime = date_div['title']
# Extract the user's name from the 'from_name' div
user_div = message_div.find('div', class_='from_name')
user = user_div.get_text(strip=True) if user_div else 'Unknown User'
# Extract the message text from the 'text' div
text_div = message_div.find('div', class_='text')
message_text = text_div.get_text(strip=True) if text_div else ''
# Format the message as [datetime] User: Message
formatted_message = f"[{datetime}] {user}: {message_text}"
messages.append(formatted_message)
return messages
def save_messages_to_file(messages, output_file):
# Save the extracted messages to a file
with open(output_file, 'w', encoding='utf-8') as f:
for message in messages:
f.write(message + '\n')
def main():
# Set up argument parsing
parser = argparse.ArgumentParser(description="Parse an HTML chat log and save messages to a text file.")
parser.add_argument('html_file', help='Path to the input HTML file')
# Parse the arguments
args = parser.parse_args()
# Get the HTML file and corresponding output filename
html_file = args.html_file
output_file = os.path.splitext(html_file)[0] + '.txt'
# Parse the HTML file to extract messages
messages = parse_html_file(html_file)
# Save the messages to the output text file
save_messages_to_file(messages, output_file)
print(f"Messages saved to {output_file}")
if __name__ == '__main__':
main()

Далее выполнить команду в PowerShell:

PS > cd “C:\Users\user\Downloads\Telegram Desktop\ChatExport_2024-10-07” PS C:\Users\user\Downloads\Telegram Desktop\ChatExport_2024-10-07> python.exe .\parse.py .\messages.htm

3. Загрузить messages.txt в ChatGPT

4. Дать вводные установки chatGPT для дальнейшей работы с данными

Прочитай файл, проанализируй и запомни его содержимое. Это выгрузка чата, содержащего информацию по темам (нужные темы). Далее я буду задавать тебе вопросы, а ты будешь формировать статьи в формате википедии, соблюдая синтаксис DocuWiki.

5. Запрашивать генерацию статей в синтаксисе DocuWiki аналогично предыдущему разделу

Пример работы в подобном формате: https://chatgpt.com/share/67046c95-411c-8011-a93d-56ed18772057