Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,10 @@ model_id = "gpt2"
|
|
| 15 |
modelgpt2 = GPT2LMHeadModel.from_pretrained(model_id).to(device)
|
| 16 |
tokenizergpt2 = GPT2TokenizerFast.from_pretrained(model_id)
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def text_to_sentences(text):
|
| 19 |
clean_text = text.replace('\n', ' ')
|
| 20 |
return re.split(r'(?<=[^A-Z].[.?]) +(?=[A-Z])', clean_text)
|
|
|
|
| 15 |
modelgpt2 = GPT2LMHeadModel.from_pretrained(model_id).to(device)
|
| 16 |
tokenizergpt2 = GPT2TokenizerFast.from_pretrained(model_id)
|
| 17 |
|
| 18 |
+
def count_words(text):
|
| 19 |
+
words = text.split() # Split the text into a list of words
|
| 20 |
+
return len(words)
|
| 21 |
+
|
| 22 |
def text_to_sentences(text):
|
| 23 |
clean_text = text.replace('\n', ' ')
|
| 24 |
return re.split(r'(?<=[^A-Z].[.?]) +(?=[A-Z])', clean_text)
|