mirror of
https://github.com/Ai-hack-MAGNUM-OPUS/backend.git
synced 2024-11-24 09:13:44 +03:00
34 lines
707 B
Python
34 lines
707 B
Python
import os
|
|
|
|
from checker.services.generators import generate_charset
|
|
|
|
|
|
def _base_process(text):
|
|
paragraphs = {}
|
|
c = 1
|
|
title = True
|
|
for line in text:
|
|
if title:
|
|
if line and len(line) > 2 and line[:2] == "1.":
|
|
title = False
|
|
else:
|
|
if line:
|
|
paragraphs[c] = line
|
|
c += 1
|
|
return paragraphs
|
|
|
|
|
|
def process_paragraphs(text):
|
|
text = text.split("\n")
|
|
return _base_process(text)
|
|
|
|
|
|
def process_word_paragraphs(text):
|
|
text = text.split("\\r")
|
|
print(text)
|
|
return _base_process(text)
|
|
|
|
|
|
def media_upload_path(instance, filename):
|
|
return os.path.join(f"uploads/{generate_charset(7)}/", filename)
|