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) => {
text
});
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', [
path.join(__dirname, '..', 'python', 'auto-answer', 'scrapper.py'),
title,
......@@ -44,8 +44,8 @@ exports.createQuestion = async (req, res, next) => {
pythonScript.stdout.on('data', (data) => {
console.log('DATA FROM PYTHON IS HERE' + data);
});
pythonScript.stdout.on('end', function () {
console.log('PYTHON SCRIPT HAS BEEN ENDED');
pythonScript.stderr.on('data', (data) => {
console.log('PYTHON SCRIPT ERROR : ' + data);
});
} catch (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
import re
class Github:
class GithubData:
"""
A class to manage the Github API.
"""
def __init__(self):
def __init__(self, title):
"""
Initialize the Github API.
"""
print(title)
def get_github_resources(self, query):
"""
......
......@@ -2,7 +2,7 @@ from youtube import Youtube
from Medium import Medium
from Dev import DevTo
from stof import STOF
from Github import Github
from github import GithubData
import sys
from database import get_database
......@@ -17,7 +17,7 @@ def saveAnswer(ans_id, stackoverflow, videos, medium_r, dev_r, github_r):
{"_id": ObjectId(ans_id)},
{
"$set": {
"loading":False,
"loading": False,
"youtube": videos,
"stackoverflow": stackoverflow,
"medium_articles": medium_r.get("blogs", []),
......@@ -48,7 +48,7 @@ def saveAnswer(ans_id, stackoverflow, videos, medium_r, dev_r, github_r):
if __name__ == "__main__":
# 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"
tags = sys.argv[2] # ["flutter","java"]
AUTO_ANS_ID = sys.argv[3] # "611feaff2c4db730e56d78e8"
......@@ -57,7 +57,7 @@ if __name__ == "__main__":
medium = Medium(title, tags)
devto = DevTo(title, tags)
youtube = Youtube(title, tags)
github = Github()
github = GithubData(title)
ans = stack.searchQuestion()
medium_articels = medium.getMediumArticles()
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