coldnasser commited on
Commit
cd2e1d7
·
1 Parent(s): 3c89f2b

new preprocessing function added

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -31,19 +31,19 @@
31
  import gradio as gr
32
  from transformers import pipeline
33
  import re
34
- def clean_text(text):
35
- # Remove mentions (@username)
36
- text = re.sub(r'@\w+', '', text)
37
 
38
- # Remove URLs
39
- text = re.sub(r'http\S+|www\S+', '', text)
40
 
41
 
42
- # Remove special characters, numbers, and extra spaces
43
- text = re.sub(r'[^a-zA-Z\s]', '', text) # Keep only letters and spaces
44
- text = re.sub(r'\s+', ' ', text).strip() # Remove extra spaces
45
 
46
- return text
47
 
48
 
49
  # Define the mapping from label to human-readable status
@@ -57,7 +57,7 @@ classifier = pipeline("text-classification", model="coldnasser/depression-anxiet
57
 
58
  def predict(text):
59
  try:
60
- text=clean_text(text=text)
61
  result = classifier(text)[0] # Get the first result
62
  label = result['label']
63
  score = result['score']
 
31
  import gradio as gr
32
  from transformers import pipeline
33
  import re
34
+ # def clean_text(text):
35
+ # # Remove mentions (@username)
36
+ # text = re.sub(r'@\w+', '', text)
37
 
38
+ # # Remove URLs
39
+ # text = re.sub(r'http\S+|www\S+', '', text)
40
 
41
 
42
+ # # Remove special characters, numbers, and extra spaces
43
+ # text = re.sub(r'[^a-zA-Z\s]', '', text) # Keep only letters and spaces
44
+ # text = re.sub(r'\s+', ' ', text).strip() # Remove extra spaces
45
 
46
+ # return text
47
 
48
 
49
  # Define the mapping from label to human-readable status
 
57
 
58
  def predict(text):
59
  try:
60
+ # text=clean_text(text=text)
61
  result = classifier(text)[0] # Get the first result
62
  label = result['label']
63
  score = result['score']