Beispiel #1
0
def dataset():
    """Fixture for standard dataset"""
    print("setup")
    doxil_dataset = ReviewDataset('TEST', 'WebMD')
    doxil_dataset.load()

    yield doxil_dataset

    print("teardown")
    final_dataset_name = 'doxil-dataset-' + str(date.today()) + '.pickle'
    filenames = [
        'doxil-dataset.pickle', 'doxil-reviews.json', 'doxil-reviews.csv',
        'test-url-dataset.pickle', final_dataset_name
    ]

    for name in filenames:
        if os.path.exists(name):
            os.remove(name)
Beispiel #2
0
def test_init_everydayhealth():
    """Test the name is lowercased during init"""
    dataset = ReviewDataset('test', 'EverydayHealth')
    assert dataset.drug_name == 'test'
    assert dataset.scraper == 'EverydayHealth'
Beispiel #3
0
def test_init_drugratingz():
    """Test the name is lowercased during init"""
    dataset = ReviewDataset('test', 'DrugRatingz')
    assert dataset.drug_name == 'test'
    assert dataset.scraper == 'DrugRatingz'
Beispiel #4
0
def test_collect_everydayhealth_urls():
    """Test collect urls"""
    dataset = ReviewDataset('test-url', 'EverydayHealth')
    dataset.collect_urls('test-urls.csv')
    assert os.path.exists('testurl-dataset.pickle')
    os.remove('testurl-dataset.pickle')
Beispiel #5
0
def test_collect_drugratingz_urls():
    """Test collect urls"""
    dataset = ReviewDataset('test-url', 'DrugRatingz')
    dataset.collect_urls('test-urls.csv')
    assert os.path.exists('testurl-dataset.pickle')
    os.remove('testurl-dataset.pickle')
Beispiel #6
0
def main():
    """ Main function.
    """

    review_dataset = ReviewDataset('Citalopram', 'WebMD')
    url = 'https://www.webmd.com/drugs/drugreview-1701-citalopram-oral.aspx?drugid=1701&drugname=citalopram-oral'
    review_dataset.collect(url)
    review_dataset.save()
    # review_dataset.load()
    # review_dataset.final_save()
    review_dataset.generate_rating_webmd()
    review_dataset.print_stats()
    review_dataset.print_meta()