<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""Module that defines individual articles within citeseerx"""

import re

from bs4 import BeautifulSoup
import requests


class Article(object):
    """An article from the citeseer-x database"""

    def __init__(self):
        self.authors = None
        self.doi = None
        self.soup = None
        self.url = None

    def base_article_url(self):
        """Returns the base URL that will link to a paper
        after a DOI string is appended

        :returns: string -- base URL string
        """
        return("http://citeseerx.ist.psu.edu/viewdoc/summary?doi=")

    def create_full_url(self, doi_string):
        """Create full url to article from a DOI string

        :param doi_string:
        """
        return(self.base_article_url() + doi_string)

    def _get_authors_soup(self, find_index=0):
        """Get the authors HTML from self.soup
        """
        author_sting = self.soup.\
            find_all('div', id="docAuthors")[find_index]
        return(author_sting)

    def _get_authors_soup_text(self, author_soup):
        """Get the string contents from the authors soup<commit_msg>allow article to be constructed with no params, doi, or url<commit_after>#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""Module that defines individual articles within citeseerx"""

import re

from bs4 import BeautifulSoup
import requests


class Article(object):
    """An article from the citeseer-x database"""

    def __init__(self, doi=None, url=None,
                 base_url="http://citeseerx.ist.psu.edu/viewdoc/summary?doi="):
        self.base_url = base_url
        if doi is not None:
            assert isinstance(doi, str), "doi needs to be a string"
            self.doi = doi
            self.url = self.base_url + doi
        elif url is not None:
            assert isinstance(url, str), "url needs to be a string"
            self.url = url
            self.doi = self.parse_url_get_doi(self.url)
        else:
            self.doi = None
            self.url = None

        self.authors = None
        self.soup = None

    def base_article_url(self):
        """Returns the base URL that will link to a paper
        after a DOI string is appended

        :returns: string -- base URL string
        """
        return("http://citeseerx.ist.psu.edu/viewdoc/summary?doi=")

    def create_full_url(self, doi_string):
        """Create full url to article from a DOI string

        :param doi_string:
        """
        return(self.base_article_url() + doi_string)

    def _get_authors_soup(self, find_index=0):
        """Get the authors HTML from self.soup
        """
        author_sting = self.soup.\
            find_all('div', id="docAuthors")[find_index]
        return(author_sting)

    def _get_authors_soup_text(self, author_soup):
        """Get the string contents from the authors soup
{'fraction_non_alphanumeric': 0.10281980742778542, 'fraction_numerical': 0.0020632737276478678, 'mean_word_length': 2.3398392652123996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '508698', 'n_tokens_mistral': 901, 'n_tokens_neox': 846, 'n_words': 258}