Instructions to use fransiskaarthaa/text-summarize-fix with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use fransiskaarthaa/text-summarize-fix with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://fransiskaarthaa/text-summarize-fix") - Notebooks
- Google Colab
- Kaggle
Download text_processing.py from fransiskaarthaa/text-summarize-fix: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/fransiskaarthaa/text-summarize-fix/resolve/main/text_processing.py
- Command line
-
hf download hf://fransiskaarthaa/text-summarize-fix/text_processing.py
-
curl -L -o text_processing.py https://huggingface.co/fransiskaarthaa/text-summarize-fix/resolve/main/text_processing.py
1.16 kB
| import re | |
| def clean_text(text): | |
| """Pembersihan teks yang lebih robust""" | |
| if not isinstance(text, str): | |
| return "" | |
| # Remove extra whitespaces | |
| text = re.sub(r'\s+', ' ', text) | |
| # Remove special characters but keep punctuation | |
| text = re.sub(r'[^\w\s.,!?;:\-()]', '', text) | |
| # Remove multiple punctuation | |
| text = re.sub(r'[.,!?;:]{2,}', '.', text) | |
| return text.strip() | |
| def simple_sentence_tokenize(text): | |
| """Tokenisasi kalimat sederhana tanpa NLTK""" | |
| # Bersihkan teks terlebih dahulu | |
| text = text.replace('\n', ' ').strip() | |
| # Pisahkan berdasarkan tanda baca umum | |
| sentences = [] | |
| for part in re.split(r'(?<=[.!?])\s+', text): | |
| if part.strip(): | |
| sentences.append(part.strip()) | |
| # Jika tidak ada kalimat yang ditemukan, kembalikan seluruh teks sebagai satu kalimat | |
| if not sentences: | |
| return [text] | |
| return sentences | |
| def tokenize_words(text): | |
| """Tokenisasi kata sederhana tanpa NLTK""" | |
| text = text.lower() | |
| # Bersihkan teks | |
| text = re.sub(r'[^\w\s]', ' ', text) | |
| # Split kata-kata | |
| return [word for word in text.split() if word.strip()] | |