Skip to content

Commit

Permalink
feat: Refactor normalize_case function in utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
TanookiVerde committed Aug 19, 2024
1 parent ea6671f commit 1e4eb4b
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import jwt
import hashlib
import json
import nltk
from typing import Literal
from loguru import logger
from passlib.context import CryptContext
Expand All @@ -12,7 +11,6 @@
from app.models import User


nltk.download('punkt_tab')
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")


Expand Down Expand Up @@ -141,24 +139,5 @@ def read_timestamp(timestamp: int, output_format=Literal['date','datetime']) ->
raise ValueError("Invalid format")

def normalize_case(text):
if not text:
return None

processed_lines = []
for line in text.splitlines():
pre_symbol = ''
if line.startswith('#'):
pre_symbol = '#'
line = line[1:]
if line.startswith('-'):
pre_symbol = '-'
line = line[1:]
line = line.strip()

sentences = nltk.tokenize.sent_tokenize(line)
normalized_sentences = [sentence.capitalize() for sentence in sentences]
normalized_text = pre_symbol + ' ' + ' '.join(normalized_sentences)

processed_lines.append(normalized_text)

return '\n'.join(processed_lines)
# TODO
return text

0 comments on commit 1e4eb4b

Please sign in to comment.