Method: AnyStyle::Refs#initial_score

Defined in:
lib/anystyle/refs.rb

#initial_score(a, b) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/anystyle/refs.rb', line 185

def initial_score(a, b)
  case
  when b.match(/^\p{Ll}/) && !b.match(/^(de|v[oa]n|v\.)\s/)
    1.5
  when a.match(/\p{L}$/) && b.match(/^\p{L}/)
    1
  when b.match(/^["'”„’‚´«「『‘“`»]/)
    1
  when b.match(/^(url|doi|isbn|vol)\b/i)
    1.5
  when b.match(/^([\p{Pd}_*][\p{Pd}_* ]+|\p{Co})/)
    -1.5
  when b.match(/^\((1[4-9]|2[01])\d\d\)/) && !a.match(/(\p{Lu}|al|others)\.$/)
    -1
  when b.match(/^\p{Lu}[\p{Ll}-]+,?\s\p{Lu}/) && !a.match(/\p{L}$/)
    -0.5
  when match_list?(b)
    if match_list?(a)
      -1.5
    else
      -0.75
    end
  when b.match(/^\p{L}+:/), b.match(/^\p{L}+ \d/)
    0.5
  else
    0
  end
end