Commit fbd26b5d authored by dasunx's avatar dasunx

Github search filenaming issues configured

parent 17231558
...@@ -34,7 +34,7 @@ exports.createQuestion = async (req, res, next) => { ...@@ -34,7 +34,7 @@ exports.createQuestion = async (req, res, next) => {
text text
}); });
res.status(201).json(question); res.status(201).json(question);
const autoAnswer = await AutomatedAnswer.create({ question: question._id }); const autoAnswer = await AutomatedAnswer.create({ question: question._id, loading: true });
const pythonScript = spawn('python', [ const pythonScript = spawn('python', [
path.join(__dirname, '..', 'python', 'auto-answer', 'scrapper.py'), path.join(__dirname, '..', 'python', 'auto-answer', 'scrapper.py'),
title, title,
...@@ -44,8 +44,8 @@ exports.createQuestion = async (req, res, next) => { ...@@ -44,8 +44,8 @@ exports.createQuestion = async (req, res, next) => {
pythonScript.stdout.on('data', (data) => { pythonScript.stdout.on('data', (data) => {
console.log('DATA FROM PYTHON IS HERE' + data); console.log('DATA FROM PYTHON IS HERE' + data);
}); });
pythonScript.stdout.on('end', function () { pythonScript.stderr.on('data', (data) => {
console.log('PYTHON SCRIPT HAS BEEN ENDED'); console.log('PYTHON SCRIPT ERROR : ' + data);
}); });
} catch (error) { } catch (error) {
next(error); next(error);
......
import spacy
from collections import Counter
from string import punctuation
class keywords:
"""
A class to extract technical related keywords from a text
"""
def __init__(self, text):
"""
Initialize a keyword object
"""
self.text = text
self.spacy_nlp = spacy.load("en_core_web_lg")
def extract(self):
"""
Extract keywords from the text
"""
result = []
pos_tag = ["PROPN", "ADJ", "NOUN"]
doc = self.spacy_nlp(self.text.lower())
for token in doc:
if (
token.text in self.spacy_nlp.Defaults.stop_words
or token.text in punctuation
):
continue
if token.pos_ in pos_tag:
result.append(token.text)
return result
...@@ -3,15 +3,16 @@ from search_engine_parser import GoogleSearch ...@@ -3,15 +3,16 @@ from search_engine_parser import GoogleSearch
import re import re
class Github: class GithubData:
""" """
A class to manage the Github API. A class to manage the Github API.
""" """
def __init__(self): def __init__(self, title):
""" """
Initialize the Github API. Initialize the Github API.
""" """
print(title)
def get_github_resources(self, query): def get_github_resources(self, query):
""" """
......
...@@ -2,7 +2,7 @@ from youtube import Youtube ...@@ -2,7 +2,7 @@ from youtube import Youtube
from Medium import Medium from Medium import Medium
from Dev import DevTo from Dev import DevTo
from stof import STOF from stof import STOF
from Github import Github from github import GithubData
import sys import sys
from database import get_database from database import get_database
...@@ -17,7 +17,7 @@ def saveAnswer(ans_id, stackoverflow, videos, medium_r, dev_r, github_r): ...@@ -17,7 +17,7 @@ def saveAnswer(ans_id, stackoverflow, videos, medium_r, dev_r, github_r):
{"_id": ObjectId(ans_id)}, {"_id": ObjectId(ans_id)},
{ {
"$set": { "$set": {
"loading":False, "loading": False,
"youtube": videos, "youtube": videos,
"stackoverflow": stackoverflow, "stackoverflow": stackoverflow,
"medium_articles": medium_r.get("blogs", []), "medium_articles": medium_r.get("blogs", []),
...@@ -48,7 +48,7 @@ def saveAnswer(ans_id, stackoverflow, videos, medium_r, dev_r, github_r): ...@@ -48,7 +48,7 @@ def saveAnswer(ans_id, stackoverflow, videos, medium_r, dev_r, github_r):
if __name__ == "__main__": if __name__ == "__main__":
# title = input("Enter question title: ") # title = input("Enter question title: ")
title = sys.argv[1] title = sys.argv[1]
# "what are the benefits of using java for mobile app development over flutter" # "what are the benefits of using java for mobile app development over flutter"
tags = sys.argv[2] # ["flutter","java"] tags = sys.argv[2] # ["flutter","java"]
AUTO_ANS_ID = sys.argv[3] # "611feaff2c4db730e56d78e8" AUTO_ANS_ID = sys.argv[3] # "611feaff2c4db730e56d78e8"
...@@ -57,7 +57,7 @@ if __name__ == "__main__": ...@@ -57,7 +57,7 @@ if __name__ == "__main__":
medium = Medium(title, tags) medium = Medium(title, tags)
devto = DevTo(title, tags) devto = DevTo(title, tags)
youtube = Youtube(title, tags) youtube = Youtube(title, tags)
github = Github() github = GithubData(title)
ans = stack.searchQuestion() ans = stack.searchQuestion()
medium_articels = medium.getMediumArticles() medium_articels = medium.getMediumArticles()
dev_articles = devto.get_dev_articles() dev_articles = devto.get_dev_articles()
......
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