# url file part
from django.contrib import admin
from django.urls import path
from . import views
#NOTE THAT path('url a jai nam dakhabe sei nam or url a jai nam likhle ai page e jabe' , views.function name , name="ja iccha namedebo")
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.index, name="index1"),
path('analyze', views.analyze, name="analyze1")
#path('removepunc', views.removepunc, name="removepunc1"),
# path('capitalizedfirst', views.capitalizedfirst, name="capitalizedfirst1"),
# path('newlineremove', views.newlineremove, name="newlineremove1"),
# path('spaceremove', views.spaceremove, name="spaceremove1"),
# path('charcount', views.charcount, name="charcount1")
]
#view part
#read me
#Akhon from thake deta nebo ar terminal a print korbo
from django.http import HttpResponse
from django.shortcuts import render
def index(request):
return render(request, 'index.html')
def analyze(request):
djtext=request.GET.get('texto', 'na_paile_default')
removepunc = request.GET.get('removepunc', 'off')
print(removepunc)
#print(djtext)
if (removepunc=="on"):
punctuations='''!()-[]{};:'"\,<>./?@#$%^&*_~'''
analyzed=""
for char in djtext:
if char not in punctuations:
analyzed=analyzed+char
params={'purpose': 'removed punctuations' ,'analyzed_text':analyzed}
return render(request,'analyze.html',params)
else:
return HttpResponse("error")
# def removepunc(request):
# # ai line ta eterminal a print kore oi given value ta
# djtext=request.GET.get('texto', 'na_paile_default')
# print(djtext)
# return HttpResponse("punc remove korbe")
#
#
# def capitalizedfirst(request):
# return HttpResponse("capitalized korbe")
#
#
# def newlineremove(request):
# return HttpResponse("newline remove korbe")
#
#
# def spaceremove(request):
# return HttpResponse("space remove korbe")
#
# def charcount(request):
# return HttpResponse("character count korbe")
#Aibar html thake access korbo dictio er value gula
<!--HTML PART ######################################################################-->
<body>
<!--Creating a form and take css data from browser console-->
<h1>Welcome to the text analizer</h1>
<p>Enter your text below</p>
<br>
<!--get ar pose namee 2 ta mathod hoi from a aita likhte hoi from submit korte hole-->
<form action="/analyze" method="get" >
<textarea name="texto" style="margin: 0px; width: 1344px; height: 179px;">
</textarea>
<!--add checkbox -->
<input type="checkbox" name="removepunc"> Remove puncutation </br>
<!--add analize button-->
<button type="submit">Analize text</button>
</form>
</body>
<!--HTML PART analyze text ######################################################################-->
<body>
<h1>Your analyzed text - {{ purpose }}</h1>
<p>
{{analyzed_text}}
</p>
Comments
Post a Comment