anystyle-parser 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY.md CHANGED
@@ -1,5 +1,6 @@
1
- 0.0.5 / 2011-09-06
1
+ 0.0.6 / 2011-09-06
2
2
  ==================
3
+ * Added location normalizer
3
4
  * Improved punctuation feature elicitation
4
5
  * Improved name tokenizing
5
6
  * Bugfixes
@@ -136,6 +136,14 @@ module Anystyle
136
136
  :'internal-braces'
137
137
  when /^[\(\[\{<].*[>\}\]\)]$/
138
138
  :braces
139
+ when /^[\(\[\{<]/
140
+ :'opening-braces'
141
+ when /[>\}\]\)][\.]$/
142
+ :'terminal-closing-braces'
143
+ when /[>\}\]\)][,;:-]$/
144
+ :'internal-closing-braces'
145
+ when /^[>\}\]\)]$/
146
+ :'closing-braces'
139
147
  when /[,;:-]$/
140
148
  :internal
141
149
  when /[!\?\."']$/
@@ -311,6 +311,24 @@ module Anystyle
311
311
  warn e.message
312
312
  hash
313
313
  end
314
+
315
+ def normalize_location(hash)
316
+ location, *dangling = hash[:location]
317
+ unmatched(:pages, hash, dangling) unless dangling.empty?
318
+
319
+ location.gsub!(/^\W+|\W+$/, '')
320
+
321
+ if !hash.has_key?(:publisher) && location =~ /:/
322
+ location, publisher = location.split(/\s*:\s*/)
323
+ hash[:publisher] = publisher
324
+ end
325
+
326
+ hash[:location] = location
327
+ hash
328
+ rescue => e
329
+ warn e.message
330
+ hash
331
+ end
314
332
 
315
333
  private
316
334
 
@@ -169,7 +169,7 @@ module Anystyle
169
169
  hash[:type] = :book
170
170
  when keys.include?(:institution)
171
171
  hash[:type] = :techreport
172
- when keys.include?(:school)
172
+ when keys.include?(:school) || text =~ /master('s)?\s+thesis/i
173
173
  hash[:type] = :mastersthesis
174
174
  when text =~ /unpublished/i
175
175
  hash[:type] = :unpublished