Commit 0a421d4b authored by SohanDanushka's avatar SohanDanushka

Committing for text analysis 1

parent 1fd5beac
from rest_framework.views import APIView
from rest_framework.response import Response
from . logic import classroom_activity
from . logic import classroom_activity, text_analysis as ta
class ActivityRecognitionAPI(APIView):
......@@ -11,4 +11,15 @@ class ActivityRecognitionAPI(APIView):
def post(self, request):
video_name = request.data['video_name']
percentages = classroom_activity.activity_recognition(video_name)
return Response({"response": percentages})
\ No newline at end of file
return Response({"response": percentages})
# this class will be used to retrieve audio analysis for a lecture
class GetLectureAudioAnalysis(APIView):
def get(self, request):
analysis = ta.run()
return Response({
"response":analysis
})
\ No newline at end of file
Good morning everyone, I hope you went through the previous lecture slides, which is an overview on the OOP module.
Today our lecture is based an introduction to Object Oriented Programming Concepts.
OBJECT ORIENTED PROGRAMMING is a programming concept that works on the principles.
The main principles are abstraction, encapsulation, inheritance, and polymorphism.
OOP allows users to create the objects that they want and then, create methods to handle those objects.
The basic concept of OOPs is to create objects, re-use them throughout the program, and manipulate these objects to get results.
Object Oriented Programming popularly known as OOP, is used in a modern programming language like Java.
er Now Let’s what are Core OOPS concepts.
First one is class.
The class is a group of similar entities.
It is only an logical component which means it is not a physical entity.
hmm Now let’s go for example, if you had a class called “Expensive Cars” the object could be like Mercedes, BMW, Toyota, etc.
and the properties an be price or speed of these cars.
While the methods may be performed with these cars are driving, reverse, braking.
Next core concept is object.
An object can be defined as an instance of a class, and there can be multiple instances of a class in a program.
An Object contains both the data and the function, which operates on the data. uh For example - chair, bike, marker, pen, table.
Next, we have Inheritance. What is inheritance.
Inheritance is an OOPS concept in which one object acquires the properties and behaviours of the parent object.
It’s creating a parent-child relationship between two classes.
It offers robust and natural mechanism for organizing and structure of any software.
An abstraction is an act of representing essential features without including background details.
It is a technique of creating a new data type that is suited for a specific application.
Now let’s see an example er, while driving a car, you do not have to be concerned with its internal working.
Here you just need to concern about parts like steering wheel, Gears, accelerator.
Ok so do you know what is Encapsulation? It is an OOP method wrapping the data and code.
In this OOPS idea, the factors of a class are constantly hidden different classes.
It must be gotten to utilizing the techniques for their present class.
For instance - in school, an understudy can't exist without a class.
Rest of the oop core concepts will be discussed in our next lecture.
Hmm Before we end the lecture I will tell you some advantages of oop.
OOP offers easy to understand and a clear modular structure for programs.
Objects created for Object-Oriented Programs can be reused in other programs.
Thus it saves significant development cost.
Large programs are difficult to write, but if the development and designing team follow OOPS concept then they can better design with minimum flaws.
It also enhances program modularity because every object exists independently.
So, that is it for today's lecture on this module.
I hope you'll get a brief idea on the OOP basic concept's, which we discussed on the lecture.
If you have any questions regarding this lesson, please ask.
Here is my contact information.
See you guys on next week.
import scripts
import re
import os
def run():
# this dictionary will be returned
analysis = {}
# define the BASE path
BASE_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
FILE_PATH = os.path.join(BASE_PATH, "LecturerApp\\lecture_Notes\\sample_text2.txt")
# regex = re.compile('[@!#$%^&*()<>?{}.,:;~_-]')
#
# if(regex.search(string) == None):
# print("String is accepted")
# else:
# print("\nString is not accepted.\n")
text = open(FILE_PATH, "r", encoding="utf8")
d = dict()
number_of_words = 0
lexical_count = 0
non_lexical_count = 0
for line in text:
line = line.strip()
line = line.lower()
line_text = line.split(" ")
# incrementing the no. of words
number_of_words += len(line_text)
words = line.split(" ")
for word in words:
if word in d:
d[word] = d[word] + 1
else:
d[word] = 1
# the key words are "extraneous filler words(ok, well, like, Actually, Basically, that, jest, only, really, very, now, simply, maybe, perhaps, somehow, almost, slightly, seemed ....)"
for key in list(d.keys()):
if (key == "like"):
lexical_count += d[key]
# print('\n number of occurrences: (like)', d[key])
elif (key == "ok"):
lexical_count += d[key]
# print('\n number of occurrences (ok)', d[key])
elif(key == "now"):
lexical_count += d[key]
# print('\n number of occurrences (now)', d[key])
elif (key == "simply"):
lexical_count += d[key]
# print('\n number of occurrences (simply)', d[key])
elif (key == "well"):
lexical_count += d[key]
# print('\n number of occurrences (well)', d[key])
elif (key == "actually"):
lexical_count += d[key]
# print('\n number of occurrences (actually)', d[key])
elif (key == "basically"):
lexical_count += d[key]
# print('\n number of occurrences (basically)', d[key])
elif (key == "that"):
lexical_count += d[key]
# print('\n number of occurrences (that)', d[key])
# "jest" newei bn "just"
elif (key == "just"):
lexical_count += d[key]
# print('\n number of occurrences (just)', d[key])
elif (key == "only"):
lexical_count += d[key]
# print('\n number of occurrences (only)', d[key])
elif (key == "really"):
lexical_count += d[key]
# print('\n number of occurrences (really)', d[key])
elif (key == "very"):
lexical_count += d[key]
# print('\n number of occurrences (very)', d[key])
elif (key == "maybe"):
lexical_count += d[key]
# print('\n number of occurrences (maybe)', d[key])
elif (key == "perhaps"):
lexical_count += d[key]
# print('\n number of occurrences (perhaps)', d[key])
elif (key == "somehow"):
lexical_count += d[key]
# print('\n number of occurrences (somehow)', d[key])
elif (key == "almost"):
lexical_count += d[key]
# print('\n number of occurrences (almost)', d[key])
elif (key == "slightly"):
lexical_count += d[key]
# print('\n number of occurrences (slightly)', d[key])
elif (key == "seemed"):
lexical_count += d[key]
# print('\n number of occurrences (seemed)', d[key])
# "non-lexical filled pauses(um, uh, erm, hmm, uuh, er, ....)"
elif(key == "hmm"):
non_lexical_count += d[key]
# print('\n number of occurrences (hmm)', d[key])
elif (key == "um"):
non_lexical_count += d[key]
# print('\n number of occurrences (um)', d[key])
elif (key == "uh"):
non_lexical_count += d[key]
# print('\n number of occurrences (uh)', d[key])
elif (key == "erm"):
non_lexical_count += d[key]
# print('\n number of occurrences (erm)', d[key])
elif (key == "er"):
non_lexical_count += d[key]
# print('\n number of occurrences (er)', d[key])
elif (key == "uuh"):
non_lexical_count += d[key]
# print('\n number of occurrences (uuh)', d[key])
data = text.read()
num_words = data.split("\n")
# print("\nThe number of words in the document : ", number_of_words)
#
#
# print("\nNumber of extraneous filler words spoken : ", lexical_count)
#
#
# print("\nNumber of non-lexical filled pauses spoken : ", non_lexical_count )
# returning the values
analysis['num_of_words'] = number_of_words
analysis['lexical_count'] = lexical_count
analysis['non_lexical_count'] = non_lexical_count
return analysis
from django.db import models
from djongo import models
# Create your models here.
......@@ -49,3 +50,19 @@ class tVideoMetaData(models.Model):
self.calStandPercent()
self.calWalkPercent()
class lectureAudio (models.Model):
lecture_audio_id = models.CharField(max_length=10)
lecturer_date = models.DateField()
lecture_audio_name = models.CharField(max_length=50)
lecture_audio_length = models.DurationField()
# lecturer = models.ForeignKey(Lecturer, on_delete=models.CASCADE, default=0)
# subject = models.ForeignKey(Subject, on_delete=models.CASCADE, default=0)
class lectureRecordedVideo (models.Model):
lecture_video_id = models.CharField(max_length=10)
lecturer_date = models.DateField()
lecture_video_name = models.CharField(max_length=50)
lecture_video_length = models.DurationField()
# lecturer = models.ForeignKey(Lecturer, on_delete=models.CASCADE, default=0)
# subject = models.ForeignKey(Subject, on_delete=models.CASCADE, default=0)
\ No newline at end of file
......@@ -29,6 +29,9 @@ urlpatterns = [
# API to retrieve activity recognition
url(r'^activities', api.ActivityRecognitionAPI.as_view()),
# API to retrieve audio analysis
url(r'^get-audio-analysis', api.GetLectureAudioAnalysis.as_view()),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]
\ No newline at end of file
......@@ -122,6 +122,11 @@ def lecVideo(request):
video.duration = str(durationObj)
videos.append(video)
print('Video Name: ', video.name)
# audio =
context = {'object': obj, 'Videos': videos, 'durations': durations, 'template_name': 'LecturerApp/template.html', 'video_name': video}
return render(request, 'LecturerApp/lecVideo.html', context)
# for audioPath in audiopaths:
# audio = tAudio()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment