Exemplo n.º 1
0
    def get(self):
        # Read in global keywords
        keywords = LoadKeywordsFromFile('data/SEG_Keywords.txt')
        keywords = LoadKeywordsFromFile('data/seg2015.json_keywords.txt',
                                        kw=keywords)

        # Populate the keywords in the db
        articles = Article.all().fetch(100000)
        for article in articles:

            if (article.title is None) or (article.abstract is None):
                continue
        
            new_kw, prob, ind = GenerateKeywords(article.abstract,
                                                 article.title,
                                                 article.keywords,
                                                 keywords)

            article.keywords = list(new_kw)
            article.kw_prob = prob
            article.kw_ind = ind
            article.put()

        Keywords(data=list(keywords)).put()
        
        self.response.out.write('worky worky')
Exemplo n.º 2
0
    def get(self):

        self.response.headers['Content-Type'] = 'application/json'

        articles = Article.all().fetch(10)

        arts = []
        kw = []
        authors = []
        for art in articles:
            arts.append(art.json)
            kw += art.keywords
            authors += art.authors

        keywords = [kw[i] for i in randint(0, len(kw), 15)]
        authors = [authors[i] for i in randint(0, len(authors), 5)]
        keywords = list(set(keywords))
        authors = list(set(keywords))
        self.response.out.write(json.dumps({'keywords': keywords,
                                            'authors': authors,
                                            'suggestions': arts}))
Exemplo n.º 3
0
    def get(self):

        self.response.headers['Content-Type'] = 'application/json'

        AuthorQuery = self.request.get('authors')
        kqv = self.request.get('keywords')

        W0 = 2.0
        W1 = 1.0
        W2 = 0.5
        articles = Article.all().fetch(100000)
        scores = []
        for article in articles:
            authors = article.authors
            kv = article.kw_prob  # get the keyword vector
            citation = article.citedby
            score = (W0 * AuthorScore(AuthorQuery, authors) +
                     W1 * KeywordScore(kqv, kv) +
                     W2 * CitationAuthorScore(AuthorQuery, citation))
            scores.append(score)
        

        self.request.out.write('success')