A tool for analyzing text data in Django backend
It is a simple django project or website in which we can Analyze text.
1)Remove Punctuations2)UPPERCASE
3)New Line Remove
4)Extra Spaces Remover
5)Numbers Remover python3
django
A tool for analyzing text data in Django backend
I searched bt didn't find the relevant stuff ...hope here i find some help........
Please pull and merge it to your website
if we have double spaces at the end of the string then issue of out of bound would arise.
possible solution :
`elif(extraspaceremover=="on"):
analyzed=re.sub(' +',' ', djtext)
params = {'purpose': 'Removed NewLines', 'analyzed_text': analyzed}
# Analyze the text
return render(request, 'analyze.html', params)`
I am trying to remove new lines from my text and i an failing every time i have tried everything that i could if You Know the Solution so please tell me that.
please help me
I have four models of the shop, customer, product, an order.
I am showing the relation of models
user = models.OneToOneField(User, null=True, related_name='shop', blank=True, on_delete=models.CASCADE)
name = models.CharField(max_length=70, null=True, default='shop', )
address = models.CharField(max_length=70, null=True)
Shop_category = models.CharField(max_length=200, null=True, )
user = models.OneToOneField(User, null=True, on_delete=models.CASCADE)
name = models.CharField(max_length=100, null=True, default='customer')
Phone = models.PositiveIntegerField(blank=True, null=True)`
shop = models.ForeignKey(Shop, models.CASCADE, null=True, blank=True)
name = models.CharField(max_length=100, blank=True)
Brand = models.CharField(max_length=200, blank=True)
description = models.TextField(null=True, blank=True)
shop = models.ForeignKey(Shop, models.CASCADE, null=True)
customer = models.ForeignKey(Customer, models.CASCADE, null=True)
product = models.ForeignKey(Product, models.CASCADE, null=True)
quantity = models.CharField(max_length=30)
date_created = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=200, choices=STATUS, default='Pending')
note = models.CharField(max_length=1000, null=True)`
when customers login then the shop will print on the screen and a button on shop to show the products by the shop in the form card. On the product card, there is an order button that adds the product in order after submitting the selected product will print with the remaining filled of order. how I can create views.py
If we add two filers both should be listed on the Analyze page, rather here only the later one in the list is displayed. Also, removed "NewLines" is a repetitive message for the last 3 actions which should be changed according to the operation. The same code is repeated in three HTML files used, rather a single file can be made with that and used. It'll not only improve the readability but will also facilitate easy changes to the design if any in future.
from django . http import HttpResponse
from django.shortcuts import render
def index(request):
return render(request, 'index.html')
def analyze(request):
#Get the text
djtext = request.POST.get('text', 'default')
#check the checkbox
removepunc = request.POST.get('removepunc', 'off')
extraspaceremover = request.POST.get('extraspaceremover','off')
fullcaps = request.POST.get('fullcaps', 'off')
newlineremover = request.POST.get('newlineremover', 'off')
countchar = request.POST.get('countchar', 'off')
numberremover = request.POST.get('numberremover','off')
print(fullcaps)
print(extraspaceremover)
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}
djtext = analyzed
if (extraspaceremover == "on"):
analyzed = ""
for index, char in enumerate(djtext):
if not(djtext[index] == " " and djtext[index + 1] == " "):
analyzed = analyzed + char
params = {'purpose': 'EXTRA SPACES REMOVED', 'analyzed_text': analyzed}
djtext = analyzed
if (fullcaps =="on"):
analyzed = ""
for char in djtext:
analyzed = analyzed + char.upper()
params = {'purpose': ' UPPER CASE', 'analyzed_text': analyzed}
djtext = analyzed
if (newlineremover =="on"):
analyzed = ""
for char in djtext:
if char !='\n' and char!='\r':
analyzed = analyzed + char
params = {'purpose': ' NEW LINE REMOVER', 'analyzed_text': analyzed}
djtext = analyzed
if (countchar =="on"):
analyzed = ""
for char in djtext:
analyzed = len(djtext)
params = {'purpose': 'COUNT CHAR', 'analyzed_text': analyzed}
djtext=analyzed
if (numberremover == "on"):
analyzed = ""
numbers = '0123456789'
for char in djtext:
if char not in numbers:
analyzed = analyzed + char
params = {'purpose': 'NUMBER REMOVED', 'analyzed_text': analyzed}
djtext = analyzed
if (removepunc!="on" and fullcaps!= "on" and newlineremover!= "on" and extraspaceremover!= "on" and countchar!= "on" and numberremover!= "on"):
return HttpResponse('Error')
return render(request, 'analyze.html', params)
on running this code it is giving an error
!!!!!!
Request Method: | POST |
---|---|
http://127.0.0.1:8000/analyze | |
3.0.6 | |
IndexError | |
string index out of range | |
C:\Users\hp\PycharmProjects\Textutils\Textutils\Textutils\views.py in analyze, line 44 | |
C:\Users\hp\AppData\Local\Programs\Python\Python38\python.exe | |
3.8.3 | |
['C:\Users\hp\PycharmProjects\Textutils\Textutils', 'C:\Users\hp\AppData\Local\Programs\Python\Python38\python38.zip', 'C:\Users\hp\AppData\Local\Programs\Python\Python38\DLLs', 'C:\Users\hp\AppData\Local\Programs\Python\Python38\lib', 'C:\Users\hp\AppData\Local\Programs\Python\Python38', 'C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages'] |
If we enter some extra spaces at the end of sentence or text then it will through an string error on screen.
The file views.py not showing the purpose or the function analyzed correctly and it just shows the only first analyzing function applied on the text and hides the next
New Line Remover Not Working With Multiple Operations
Can I try to solve it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.