Revision: 10934
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=10934&view=rev
Author: amaxwell
Date: 2007-08-17 11:04:16 -0700 (Fri, 17 Aug 2007)
Log Message:
-----------
Changes for SciFinder parsing
- remove trailing "." from author lists with full names
- save abbreviated journal name if superseded
- put index terms in annote as well
- attempt to titlecase all-caps journal names
Modified Paths:
--------------
trunk/bibdesk/BDSKSciFinderParser.m
Modified: trunk/bibdesk/BDSKSciFinderParser.m
===================================================================
--- trunk/bibdesk/BDSKSciFinderParser.m 2007-08-17 14:52:26 UTC (rev 10933)
+++ trunk/bibdesk/BDSKSciFinderParser.m 2007-08-17 18:04:16 UTC (rev 10934)
@@ -69,6 +69,7 @@
return NO;
}
+// this is a set of fields that don't need any massaging; the key/value match
BibTeX definitions
static NSSet *correctFields = nil;
+ (void)initialize
@@ -80,21 +81,46 @@
// some more-or-less unique string that meets our field name criteria (leading
cap, no space)
static NSString *__documentTypeString = @"Doc-Type";
+static void addKeyValueToAnnote(NSString *key, NSString *value,
NSMutableDictionary *pubFields)
+{
+ NSMutableString *mutString = [pubFields objectForKey:BDSKAnnoteString];
+ if (nil == mutString) {
+ mutString = [NSMutableString string];
+ [pubFields setObject:mutString forKey:BDSKAnnoteString];
+ }
+ [mutString appendFormat:@"%@:[EMAIL PROTECTED]", key, value];
+}
+
static void fixAndAddKeyValueToDictionary(NSString *key, NSString *value,
NSMutableDictionary *pubFields)
{
// We could move some of this into TypeInfo.plist, but we only have three
fields that don't need special handling, so it's not really worthwhile. This
function has multiple early returns, so be careful when debugging.
if ([key isEqualToString:BDSKAuthorString]) {
value = [value stringByReplacingAllOccurrencesOfString:@"; "
withString:@" and "];
+ // this sucks; some entries have "Last, Middle, First.", and some have
"Last, M. F."
+ if ([value hasSuffix:@"."] && [value length] > 2 &&
+ [[NSCharacterSet lowercaseLetterCharacterSet]
characterIsMember:[value characterAtIndex:([value length] - 2)]])
+ value = [value stringByRemovingSuffix:@"."];
}
else if ([key isEqualToString:@"Full Journal Title"]) {
key = BDSKJournalString;
+ // apparently one of the databases returns journal names in all caps
+ if ([value rangeOfCharacterFromSet:[NSCharacterSet
lowercaseLetterCharacterSet]].location == NSNotFound)
+ value = [value titlecaseString];
+ // if we previously used the short title, save it off in Annote
+ if ([pubFields objectForKey:key] != nil)
+ addKeyValueToAnnote(@"Journal Title", [pubFields
objectForKey:key], pubFields);
}
else if ([key isEqualToString:@"Journal Title"]) {
key = BDSKJournalString;
// if we already have a Journal definition, bail out, because it's
from "Full Journal Title"
- if ([pubFields objectForKey:key] != nil)
+ if ([pubFields objectForKey:key] != nil) {
+ addKeyValueToAnnote(key, value, pubFields);
return;
+ }
+ // apparently one of the databases returns journal names in all caps
+ if ([value rangeOfCharacterFromSet:[NSCharacterSet
lowercaseLetterCharacterSet]].location == NSNotFound)
+ value = [value titlecaseString];
}
else if ([key isEqualToString:@"Document Type"]) {
// parse this here and add to the dictionary, to be removed later when
we match it up with a BibTeX type
@@ -128,18 +154,9 @@
if ([value hasSuffix:@"."])
value = [value stringByRemovingSuffix:@"."];
}
- else if ([key isEqualToString:@"Index Terms"]) {
- // stick Index Terms(2) and Supplementary Terms in annote; user says
they're generally garbage
- key = BDSKKeywordsString;
- }
else if ([correctFields containsObject:key] == NO) {
// this is a field that isn't meaningful, so dump it into Annote
- NSMutableString *mutString = [pubFields objectForKey:BDSKAnnoteString];
- if (nil == mutString) {
- mutString = [NSMutableString string];
- [pubFields setObject:mutString forKey:BDSKAnnoteString];
- }
- [mutString appendFormat:@"%@:[EMAIL PROTECTED]", key, value];
+ addKeyValueToAnnote(key, value, pubFields);
// bail out instead of adding to the dictionary
return;
@@ -240,7 +257,7 @@
/*
Google turns up some sample documents at
- http://chemistry.library.wisc.edu/instruction/scifinder_taggedsample.txt
+
http://www.google.com/search?q=cache:3Cg15n4kCGwJ:chemistry.library.wisc.edu/instruction/scifinder_taggedsample.txt+scifinder+START_RECORD&hl=en&ct=clnk&cd=4&gl=us
http://wiki.refbase.net/index.php/Import_Example:_SciFinder
From those and user-suppled info, we have the following doc types:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit