Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lisc/collect/words.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def get_article_info(arts, article):

# Extract reference list, if present
# Otherwise, tags within this can interfere with collected data
refs = extract_tag(article, 'ReferenceList')
refs = extract_tag(article, 'ReferenceList', 'all')

arts.add_data('ids', process_ids(get_info(article, 'ArticleId', 'all'), 'pubmed'))
arts.add_data('titles', get_info(article, 'ArticleTitle', 'str'))
Expand Down
17 changes: 12 additions & 5 deletions lisc/objects/words.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,22 @@ def check_data(self):
print("\t{:{twd}} \t\t {}".format(label, data.n_articles, twd=twd))


def check_articles(self):
"""Prints out the articles collected for each term."""
def check_articles(self, header=None):
"""Print out a brief description of the articles collected for each term."""

for results in self.results:
print('\nLabel: {}\n'.format(results.label))
print('\nLabel: {} ({} articles)\n'.format(results.label, results.n_articles))
for cres in results:
author = cres['authors'][0][0] + (' et al' if len(cres['authors']) > 1 else '')
doi = 'https://dx.doi.org/' + cres['doi'] if cres['doi'] else ''
if cres['authors']:
author = cres['authors'][0][0] + (' et al' if len(cres['authors']) > 1 else '')
else:
author = 'unknown author'
if cres['doi']:
doi = 'https://dx.doi.org/' + cres['doi']
else:
doi = ''
print(author + ',', str(cres['year']) + ':', cres['title'], doi)
print('\n')


def drop_data(self, n_articles):
Expand Down
2 changes: 1 addition & 1 deletion lisc/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.5.0-dev'
__version__ = '0.4.1-dev'
7 changes: 6 additions & 1 deletion tutorials/plot_01-WordsCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@

###################################################################################################

# Check the collected words data
# Check the number of collected articles
words.check_data()

###################################################################################################

# Check the collected words results
print(words.results)

###################################################################################################
Expand Down
15 changes: 14 additions & 1 deletion tutorials/plot_02-WordsAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
#
# The `results` attribute contains a list of :class:`~.Articles` objects, one for each term.
#
# Note that the reloaded data is the raw data from the data collection.
#

###################################################################################################

Expand All @@ -92,7 +94,18 @@

###################################################################################################
#
# Note that the reloaded data is the raw data from the data collection.
# The :meth:`~.Words.check_articles` method can be used to print out a summary of the articles
# that have been collected under each search term.
#

###################################################################################################

# Check the collected articles
words.check_articles()

###################################################################################################
# Processing Collected Data
# ~~~~~~~~~~~~~~~~~~~~~~~~~
#
# The :meth:`~.Words.process_articles` method can be used to do some preprocessing on the
# collected data.
Expand Down
7 changes: 3 additions & 4 deletions tutorials/plot_06-CollectAcrossTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,10 @@

###################################################################################################

# Check the titles found across different time ranges
# Check the articles found across different time ranges
for time_period, results in word_results.items():
print(str(time_period) + 's:')
for res_title in results.results[0].titles:
print('\t', res_title)
print('---- {} ----'.format(time_period))
results.check_articles()

###################################################################################################
#
Expand Down