Skip to content

Instantly share code, notes, and snippets.

View vaibhavgehani's full-sized avatar

Vaibhav Gehani vaibhavgehani

View GitHub Profile
export class HomePage {
MovieName = '';
url = environment.modelUrl;
public recommentList: any = [];
constructor(private http: HttpClient) {}
getRecommend() {
if (this.MovieName !== '') {
this.http.get(`${this.url}?name=${this.MovieName}`).subscribe((response) => {
console.log(response);
this.recommentList = response;
<ion-header>
<ion-toolbar>
<ion-title>
Recommend Movies
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content style="background-color: gainsboro;" [fullscreen]="true">
<ion-header collapse="condense">
@app.route('/movie')
def main():
name=request.args.get('name')
print(name)
if(name != None):
recom_array=recommend_movie(name)
print(recom_array)
try:
return recom_array.to_json(orient='records')
except:
def recommend_movie(movieName,cosine_sim=cosine_sim):
try:
indx=indices[movieName]
score_tuple=list(enumerate(cosine_sim[indx]))
sorted_tuple=sorted(score_tuple,key=lambda x: x[1],reverse=True)
top_10_score=sorted_tuple[1:6]
top_10_index=[i[0] for i in top_10_score]
return movie_data[['title','spoken_languages','popularity','release_date','runtime','poster_path']].iloc[top_10_index]
except(Exception):
print('Erorr')
movie_data = pd.read_csv('movies.csv')
#Vectorization of the Words
from sklearn.feature_extraction.text import TfidfVectorizer
tfidf = TfidfVectorizer(stop_words='english')
movie_data.overview=movie_data.overview.fillna('')
tfidf_matrix = tfidf.fit_transform(movie_data.overview)
#importing linear_kernel from sklearn to get the coorelation between each movie according the overview feature of dataset
from flask import Flask,request,jsonify,Response
from flask_cors import CORS;
import pandas as pd
import json
app=Flask(__name__)
CORS(app)
#importing the dataset
movie_data = pd.read_csv('movies.csv')
#Vectorization of the Words
goToSelectfile(event: any) {
this.fileObj = event.target.files[0];
}
sendName() {
const uploadData = new FormData();
uploadData.append('file', this.fileObj);
this.http.post('http://127.0.0.1:5000/getText', uploadData).subscribe((res: any) => {
this.show = true;
this.line = res.outputText;
this.sentiment = res.predSentiment;
try:
from PIL import Image
except ImportError:
import Image
import pytesseract
def ocr_extraction(filename):
pytesseract.pytesseract.tesseract_cmd = r'C:/Users/intel/AppData/Local/Tesseract-OCR/tesseract.exe'
text=pytesseract.image_to_string(Image.open(filename))
return(text)
positive_fileids = movie_reviews.fileids('pos')
negative_fileids = movie_reviews.fileids('neg')
features_positive = [(extract_features(movie_reviews.words(fileids=[f])),'Positive') for f in positive_fileids]
features_negative = [(extract_features(movie_reviews.words(fileids=[f])),'Negative') for f in negative_fileids]