Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 6 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Showing with 64 additions and 11 deletions.
  1. +46 −5 Perl/Citematic/Get.pm
  2. +9 −0 Perl/test_citematic.pl
  3. +8 −5 Python/quickbib.py
  4. +1 −1 README.rst
View
51 Perl/Citematic/Get.pm
@@ -246,7 +246,7 @@ sub citation
sub journal_article
{my ($authors, $year, $article_title, $journal, $volume, $issue,
- $first_page, $last_page, $doi) = @_;
+ $first_page, $last_page, $doi, $url) = @_;
citation
type => 'article-journal',
author => $authors,
@@ -256,7 +256,8 @@ sub journal_article
volume => $volume,
issue => $issue,
page => digest_pages($first_page, $last_page),
- DOI => $doi;}
+ DOI => $doi,
+ URL => $url;}
sub book_chapter
{my ($authors, $year, $chapter_title, $editors, $book, $volume,
@@ -444,6 +445,9 @@ sub ebsco
: split qr[(?:,|;| and| &) ], $record{'-by'}
: split qr[;\s*|<br />], $record{Authors};
+ defined $record{'Digital Object Identifier'}
+ and $record{'Digital Object Identifier'} =~ s/[\x{0d}\x{0a}].*//s;
+
if (!$record{'Document Type'} or
$record{'Document Type'} eq 'Article' or
$record{'Document Type'} eq 'Journal Article' or
@@ -457,7 +461,7 @@ sub ebsco
return journal_article $authors, $d{year},
$title, $d{journal_title},
$d{volume}, $d{issue}, $d{first_page} || $1, $d{last_page} || $2,
- $record{'Digital Object Identifier'};}
+ $record{'Digital Object Identifier'}, undef;}
my $year;
if ($record{Source} =~ s{,?\s+\d{1,2}/\d{1,2}/(\d{4})}{})
{$year = $1;}
@@ -514,9 +518,14 @@ sub ebsco
get_doi
$year, $journal, $title,
$authors->[0]{family}, $volume, $fpage;
+ my $url;
+ lc($journal) eq 'judgment and decision making'
+ # This is an open-access journal, but it doesn't have
+ # DOIs, so get a URL.
+ and $url = sjdm_url_from_title($title);
return journal_article $authors, $year, $title,
- $journal, $volume, $issue, $fpage, $lpage, $doi;}
+ $journal, $volume, $issue, $fpage, $lpage, $doi, $url;}
elsif ($record{'Document Type'} eq 'Chapter')
@@ -533,6 +542,20 @@ sub ebsco
(?<year> \d\d\d\d) \.}x or die 'chapter';
my %src = %+;
+ if (exists $record{'Series Title'}
+ and $record{'Series Title'} =~ /\A(Annals of The New York Academy of Sciences); Vol\. (\d+)/i)
+ # Annals of the NYAS is actually a journal.
+ {my ($journal, $volume) = ($1, $2);
+ my $doi =
+ $record{'Digital Object Identifier'} ||
+ $terms{doi} ||
+ get_doi
+ $src{year}, $journal, $title,
+ $authors->[0]{family}, $volume, $src{fpage};
+ return journal_article $authors, $src{year}, $title,
+ 'Annals of the New York Academy of Sciences',
+ $volume, undef, $src{fpage}, $src{lpage}, $doi, undef;}
+
(my $book = $src{book}) =~ s/: /: /;
$src{volume} and $book =~ s/, Vol\z//;
my $editors = σ
@@ -629,7 +652,25 @@ sub ideas
return journal_article
$authors, $record{year}, $record{title},
$journal, $record{volume}, $record{issue},
- $fpage, $lpage, $doi;}
+ $fpage, $lpage, $doi, undef;}
+
+# ------------------------------------------------------------
+# Society for Judgment and Decision-Making
+# ------------------------------------------------------------
+
+sub sjdm_url_from_title
+ {my $title = shift;
+ progress 'Trying SJDM';
+ $global_cache->{sjdm}{lc($title)} ||= do
+ {my $page = LWP::Simple::get(query_url
+ 'http://www.sjdm.org/cgi-bin/namazu.cgi',
+ max => 10, result => 'normal', sort => 'score',
+ idxname => 'journal',
+ query => "{$title}");
+ # Curly braces signify an exact match in Namazu.
+ # (http://www.namazu.org/doc/manual.html#query-phrase)
+ $page =~ m/<dd><a href="(.+?)">/ or return err 'No results.';
+ $1;}}
# ------------------------------------------------------------
# Public interface
View
9 Perl/test_citematic.pl
@@ -36,6 +36,9 @@ sub apa
is apa(year => 2004, author => ['maia', 'McClelland']),
'Maia, T. V., & McClelland, J. L. (2004). A reexamination of the evidence for the somatic marker hypothesis: What participants really know in the Iowa gambling task. <i>Proceedings of the National Academy of Sciences, 101</i>(45), 16075–16080. doi:10.1073/pnas.0406666101',
'PNAS';
+is apa(year => 1997, author => ['Wallen', 'Tannenbaum']),
+ 'Wallen, K., & Tannenbaum, P. L. (1997). Hormonal modulation of sexual behavior and affiliation in rhesus monkeys. <i>Annals of the New York Academy of Sciences, 807</i>, 185–202. doi:10.1111/j.1749-6632.1997.tb51920.x',
+ 'Annals of the NYAS';
is apa(year => 1983, author => ['Tversky', 'Kahneman']),
'Tversky, A., & Kahneman, D. (1983). Extensional versus intuitive reasoning: The conjunction fallacy in probability judgment. <i>Psychological Review, 90</i>(4), 293–315. doi:10.1037/0033-295X.90.4.293',
'Psychological Review';
@@ -92,6 +95,9 @@ sub apa
is apa(year => 2006, author => ['ditto', 'pizarro']),
'Ditto, P. H., Pizarro, D. A., Epstein, E. B., Jacobson, J. A., & MacDonald, T. K. (2006). Visceral influences on risk-taking behavior. <i>Journal of Behavioral Decision Making, 19</i>(2), 99–113. doi:10.1002/bdm.520',
'Journal of Behavioral Decision Making (miscapitalized title)';
+is apa(year => 2007, author => ['levin', 'pederson']),
+ 'Levin, I. P., Weller, J. A., Pederson, A. A., & Harshman, L. A. (2007). Age-related differences in adaptive decision making: Sensitivity to expected value in risky choice. <i>Judgment and Decision Making, 2</i>(4), 225–233. Retrieved from http://journal.sjdm.org/7404/jdm7404.htm',
+ 'Judgment and Decision Making';
is apa(title => ['short-term memory', 'we stand']),
'Crowder, R. G. (1993). Short-term memory: Where do we stand? <i>Memory & Cognition, 21</i>(2), 142–145. doi:10.3758/BF03202725',
'Memory & Cognition (title search, ampersand in journal title)';
@@ -169,6 +175,9 @@ sub apa
is apa(doi => '10.1007/s11238-010-9234-3'),
'Zeisberger, S., Vrecko, D., & Langer, T. (2012). Measuring the time stability of prospect theory preferences. <i>Theory and Decision, 72</i>(3), 359–386. doi:10.1007/s11238-010-9234-3',
'Theory and Decision (DOI search, multiple years in CrossRef)';
+is apa(title => ['toward a synthesis of cognitive biases']),
+ 'Hilbert, M. (2012). Toward a synthesis of cognitive biases: How noisy information processing can bias human decision making. <i>Psychological Bulletin, 138</i>(2), 211–237. doi:10.1037/a0025940',
+ 'Psychological Bulletin (multiple DOIs in PsycINFO record)';
is apa(title => ['happiness makes us selfish']),
'Tan, H. B., & Forgas, J. P. (2010). When happiness makes us selfish, but sadness makes us fair: Affective influences on interpersonal strategies in the dictator game. <i>Journal of Experimental Social Psychology, 46</i>(3), 571–576. doi:10.1016/j.jesp.2010.01.007',
'Journal of Experimental Social Psychology (impoverished PsycINFO record)';
View
13 Python/quickbib.py
@@ -27,11 +27,12 @@ def bib1(style_path, d, **rest):
def bib(style_path,
ds,
+ also_return_keys = False,
formatter = "chocolate",
dumb_quotes = True,
- # Setting this to False won't educate any straight
- # quotes in the data, but leaving it True will stupefy
- # all the smart quotes in the output.
+ # Turning this off won't educate any straight quotes in
+ # the data, but leaving it on will stupefy all the
+ # smart quotes in the output.
apa_tweaks = True,
# The below options are ignored unless apa_tweaks is on.
always_include_issue = False,
@@ -48,7 +49,8 @@ def bib(style_path,
ds = deepcopy(ds)
for d in ds:
- d['id'] = str(random())
+ if 'id' not in d:
+ d['id'] = str(random())
for k in list(d.keys()):
if d[k] is None: del d[k]
if apa_tweaks:
@@ -76,6 +78,7 @@ def bib(style_path,
formatter)
bibliography.register(Citation(
[ CitationItem(d['id']) for d in ds ]))
+ if len(ds) > 1: bibliography.sort()
s = bibliography.bibliography()
# Fix spacing and punctuation issues.
@@ -93,7 +96,7 @@ def bib(style_path,
# Replace the ellipsis placeholder.
s = s.replace('⣥<ellipsis>⣥, ., &', '')
- return s
+ return (bibliography.keys, s) if also_return_keys else s
# ------------------------------------------------------------
# Private
View
2 README.rst
@@ -65,7 +65,7 @@ There may be some restrictions on what you can do with the data you get, which a
And, of course, since this is mostly done with web scraping, server-side changes could suddenly render Citematic::Get inoperable.
-Why didn't you use Z39.80?
+Why didn't you use Z39.50?
============================================================
I couldn't get it to work.

No commit comments for this range

Something went wrong with that request. Please try again.