Spaces:
Running
Running
aliasgerovs
commited on
Commit
•
16a43bc
1
Parent(s):
d0177bd
Added input character limit check.
Browse files
app.py
CHANGED
@@ -183,6 +183,9 @@ def remove_special_characters(text):
|
|
183 |
cleaned_text = re.sub(r'[^a-zA-Z0-9\s]', '', text)
|
184 |
return cleaned_text
|
185 |
|
|
|
|
|
|
|
186 |
def predict_bc(model, tokenizer, text):
|
187 |
tokens = tokenizer(
|
188 |
text, padding=True, truncation=True, return_tensors="pt"
|
@@ -207,7 +210,6 @@ def predict_mc(model, tokenizer, text):
|
|
207 |
mc_score[label.upper()] = score.item()
|
208 |
return mc_score
|
209 |
|
210 |
-
|
211 |
def ai_generated_test(input):
|
212 |
|
213 |
cleaned_text = remove_special_characters(input)
|
@@ -220,7 +222,6 @@ def ai_generated_test(input):
|
|
220 |
|
221 |
return bc_score, mc_score
|
222 |
|
223 |
-
|
224 |
# COMBINED
|
225 |
def main(
|
226 |
input,
|
@@ -256,12 +257,18 @@ def main(
|
|
256 |
def build_date(year, month, day):
|
257 |
return f"{year}{months[month]}{day}"
|
258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
|
260 |
# DEPTH ANALYSIS
|
261 |
print("loading depth analysis")
|
262 |
nltk.download('stopwords')
|
263 |
nltk.download('punkt')
|
264 |
-
command = ['
|
265 |
# Execute the command
|
266 |
subprocess.run(command)
|
267 |
nlp = spacy.load("en_core_web_sm")
|
@@ -339,7 +346,6 @@ def depth_analysis(input_text):
|
|
339 |
return fig
|
340 |
|
341 |
|
342 |
-
|
343 |
# START OF GRADIO
|
344 |
|
345 |
title = "Copyright Checker"
|
@@ -372,8 +378,11 @@ with gr.Blocks() as demo:
|
|
372 |
# Copyright Checker
|
373 |
"""
|
374 |
)
|
375 |
-
input_text = gr.Textbox(label="Input text", lines=
|
376 |
-
|
|
|
|
|
|
|
377 |
with gr.Row():
|
378 |
with gr.Column():
|
379 |
only_ai_btn = gr.Button("AI Check")
|
@@ -382,7 +391,7 @@ with gr.Blocks() as demo:
|
|
382 |
with gr.Column():
|
383 |
depth_analysis_btn = gr.Button("Depth Analysis")
|
384 |
with gr.Column():
|
385 |
-
|
386 |
gr.Markdown(
|
387 |
"""
|
388 |
## Output
|
@@ -413,6 +422,7 @@ with gr.Blocks() as demo:
|
|
413 |
day_from = gr.Textbox(label="From Day", value="01")
|
414 |
year_from = gr.Textbox(label="From Year", value="2000")
|
415 |
# from_date_button = gr.Button("Submit")
|
|
|
416 |
with gr.Row():
|
417 |
month_to = gr.Dropdown(
|
418 |
choices=months,
|
@@ -449,7 +459,7 @@ with gr.Blocks() as demo:
|
|
449 |
label="Writing Analysis Plot"
|
450 |
)
|
451 |
|
452 |
-
|
453 |
fn=main,
|
454 |
inputs=[
|
455 |
input_text,
|
|
|
183 |
cleaned_text = re.sub(r'[^a-zA-Z0-9\s]', '', text)
|
184 |
return cleaned_text
|
185 |
|
186 |
+
def update_character_count(text):
|
187 |
+
return f"{len(text)} characters"
|
188 |
+
|
189 |
def predict_bc(model, tokenizer, text):
|
190 |
tokens = tokenizer(
|
191 |
text, padding=True, truncation=True, return_tensors="pt"
|
|
|
210 |
mc_score[label.upper()] = score.item()
|
211 |
return mc_score
|
212 |
|
|
|
213 |
def ai_generated_test(input):
|
214 |
|
215 |
cleaned_text = remove_special_characters(input)
|
|
|
222 |
|
223 |
return bc_score, mc_score
|
224 |
|
|
|
225 |
# COMBINED
|
226 |
def main(
|
227 |
input,
|
|
|
257 |
def build_date(year, month, day):
|
258 |
return f"{year}{months[month]}{day}"
|
259 |
|
260 |
+
def len_validator(text):
|
261 |
+
min_chars = 750
|
262 |
+
if len(text) < min_chars:
|
263 |
+
return f"Input length {len(text)} ! Input must be at least {min_chars} characters long."
|
264 |
+
else :
|
265 |
+
return f"Input length satisified."
|
266 |
|
267 |
# DEPTH ANALYSIS
|
268 |
print("loading depth analysis")
|
269 |
nltk.download('stopwords')
|
270 |
nltk.download('punkt')
|
271 |
+
command = ['python3', '-m', 'spacy', 'download', 'en_core_web_sm']
|
272 |
# Execute the command
|
273 |
subprocess.run(command)
|
274 |
nlp = spacy.load("en_core_web_sm")
|
|
|
346 |
return fig
|
347 |
|
348 |
|
|
|
349 |
# START OF GRADIO
|
350 |
|
351 |
title = "Copyright Checker"
|
|
|
378 |
# Copyright Checker
|
379 |
"""
|
380 |
)
|
381 |
+
input_text = gr.Textbox(label="Input text", lines=6, placeholder="")
|
382 |
+
char_count = gr.Textbox(label="Minumum Character Limit Check")
|
383 |
+
input_text.change(fn=len_validator, inputs=input_text, outputs=char_count)
|
384 |
+
|
385 |
+
|
386 |
with gr.Row():
|
387 |
with gr.Column():
|
388 |
only_ai_btn = gr.Button("AI Check")
|
|
|
391 |
with gr.Column():
|
392 |
depth_analysis_btn = gr.Button("Depth Analysis")
|
393 |
with gr.Column():
|
394 |
+
full_check_btn = gr.Button("Full Check")
|
395 |
gr.Markdown(
|
396 |
"""
|
397 |
## Output
|
|
|
422 |
day_from = gr.Textbox(label="From Day", value="01")
|
423 |
year_from = gr.Textbox(label="From Year", value="2000")
|
424 |
# from_date_button = gr.Button("Submit")
|
425 |
+
|
426 |
with gr.Row():
|
427 |
month_to = gr.Dropdown(
|
428 |
choices=months,
|
|
|
459 |
label="Writing Analysis Plot"
|
460 |
)
|
461 |
|
462 |
+
full_check_btn.click(
|
463 |
fn=main,
|
464 |
inputs=[
|
465 |
input_text,
|