Permalink
Browse files

added reference feature

  • Loading branch information...
1 parent bfd1a7f commit 1b396fab3d5c6e763eb03162ec74ebaf5345b44b @inukshuk committed Sep 8, 2011
@@ -95,6 +95,10 @@ def match(*arguments)
:triple
when /^\d+$/
:digits
+ when /^\d+[\d-]+$/
+ :serial
+ when /^-\d+$/
+ :negative
when /\d+(th|st|nd|rd)[^[:alnum:]]*/i
:ordinal
when /\d/
@@ -185,6 +189,19 @@ def match(*arguments)
:other
end
end
-
+
+ Feature.define :reference do |token, stripped, sequence, offset|
+ case token
+ when /isbn/i
+ :isbn
+ when /^doi/i
+ :doi
+ when /^url|http|www\.[\w\.]+/i
+ :url
+ else
+ :none
+ end
+ end
+
end
end
@@ -137,7 +137,7 @@ def tokenize_names(names)
s, n, ns, cc = StringScanner.new(names), '', [], 0
until s.eos?
case
- when s.scan(/,?\s*(and\b|&)/)
+ when s.scan(/,?\s*(and\b|&|;)/)
ns << n
n, cc = '', 0
when s.scan(/\s+/)
@@ -171,7 +171,7 @@ def normalize_title(hash)
extract_edition(title, hash)
- title.gsub!(/[\.,:;\s]+$/, '')
+ title.gsub!(/^[\s]+|[\.,:;\s]+$/, '')
title.gsub!(/^["'”’´‘“`]|["'”’´‘“`]$/, '')
hash[:title] = title
@@ -216,14 +216,27 @@ def normalize_booktitle(hash)
extract_edition(booktitle, hash)
- booktitle.gsub!(/[\.,:;\s]+$/, '')
+ booktitle.gsub!(/^[\s]+|[\.,:;\s]+$/, '')
hash[:booktitle] = booktitle
hash
rescue => e
warn e.message
hash
end
+
+ def normalize_journal(hash)
+ booktitle, *dangling = hash[:journal]
+ unmatched(:journal, hash, dangling) unless dangling.empty?
+
+ journal.gsub!(/^[\s]+|[\.,:;\s]+$/, '')
+ hash[:journal] = journal
+
+ hash
+ rescue => e
+ warn e.message
+ hash
+ end
def normalize_container(hash)
container, *dangling = hash[:container]
Oops, something went wrong.

0 comments on commit 1b396fa

Please sign in to comment.