コード例 #1
0
ファイル: controller.py プロジェクト: fabiobatalha/citedby
    def query_by_pid(self, pid, collection=None, metaonly=False):

        filters = {}

        document = self.articlemeta_client.document(pid, collection=collection)

        if not document:
            return []

        article_meta = {}
        article_meta['code'] = document.publisher_id
        article_meta['start_page'] = document.start_page
        article_meta['end_page'] = document.end_page
        article_meta['first_author'] = document.authors[0] if document.authors and len(document.authors) > 0 else None
        article_meta['issn'] = document.journal.scielo_issn
        article_meta['publication_year'] = document.publication_date[0:4] if document.publication_date else None
        article_meta['url'] = document.html_url()
        article_meta['collection'] = document.collection_acronym
        article_meta['authors'] = document.authors
        article_meta['translated_titles'] = document.translated_titles()
        article_meta['doi'] = document.doi

        article_meta['titles'] = []

        if document.original_title():
            article_meta['titles'].append(document.original_title())

        if document.translated_titles():
            article_meta['titles'] + [t for l, t in document.translated_titles().items() if t]

        citations = []

        article_meta['total_received'] = 0

        if (article_meta.get('titles', False) and (article_meta.get('first_author', False) or article_meta.get('publication_year', False))):
            filters['titles'] = article_meta.get('titles', None)
            if article_meta['first_author']:
                filters['author_surname'] = ' '.join([
                    article_meta.get('first_author', {}).get('surname', ''),
                    article_meta.get('first_author', {}).get('given_names', '')
                ])
            else:
                article_meta['first_author'] == None
            filters['year'] = article_meta.get('publication_year', None)

            meta = self.search_citation(**filters)

            if meta:
                citations = format_citation(meta)
                article_meta['total_received'] = len(citations)

        if 'citations' in article_meta:
            article_meta['total_granted'] = len(article_meta['citations'])
            del(article_meta['citations'])

        if metaonly:
            return {'article': article_meta}
        else:
            return {'article': article_meta, 'cited_by': citations}
コード例 #2
0
ファイル: controller.py プロジェクト: swarzesherz/citedby
    def query_by_meta(self, title='', author_surname='', year='', metaonly=False):

        article_meta = {}
        article_meta['title'] = title
        article_meta['author'] = author_surname
        article_meta['year'] = year

        meta = self.search_citation(titles=[title], author_surname=author_surname, year=year)

        if meta:
            citations = format_citation(meta)

        article_meta['total_received'] = len(citations)

        if metaonly:
            return {'article': article_meta}
        else:
            return {'article': article_meta, 'cited_by': citations}
コード例 #3
0
ファイル: controller.py プロジェクト: swarzesherz/citedby
    def query_by_doi(self, doi, metaonly=False):

        meta = load_from_crossref(doi)

        if not meta:
            return []

        article_meta = {}
        article_meta['title'] = [meta['title']]
        article_meta['author'] = ''
        article_meta['year'] = meta['year']

        meta = self.search_citation(titles=[article_meta['title']], year=article_meta['year'])

        if meta:
            citations = format_citation(meta)

        article_meta['total_received'] = len(citations)

        if metaonly:
            return {'article': article_meta}
        else:
            return {'article': article_meta, 'cited_by': citations}