|
|
|
|
|
from transformers import AutoTokenizer
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
|
print("Loading local tokenizer...")
|
|
|
tokenizer = AutoTokenizer.from_pretrained("./tokenizer")
|
|
|
|
|
|
|
|
|
raw_chat = """
|
|
|
12/05/2025, 10:00 PM - John: Hey, are we meeting tomorrow?
|
|
|
12/05/2025, 10:01 PM - Sarah: Yes, at the cafe.
|
|
|
"""
|
|
|
|
|
|
|
|
|
def clean_text(text):
|
|
|
|
|
|
return text.replace("12/05/2025, 10:00 PM - ", "").replace("12/05/2025, 10:01 PM - ", "")
|
|
|
|
|
|
cleaned_text = clean_text(raw_chat)
|
|
|
print(f"\nCleaned Text:\n{cleaned_text}")
|
|
|
|
|
|
|
|
|
tokens = tokenizer(cleaned_text, truncation=True, padding="max_length", max_length=50)
|
|
|
|
|
|
print("\n--- Tokenization Output (First 20 tokens) ---")
|
|
|
print(f"Input IDs: {tokens['input_ids'][:20]}")
|
|
|
print(f"Attention Mask: {tokens['attention_mask'][:20]}")
|
|
|
print("\n[Success] Preprocessing module demonstrated with local tokenizer.") |