Class: AnyStyle::Feature::Keyword

Inherits:
AnyStyle::Feature show all
Defined in:
lib/anystyle/feature/keyword.rb

Instance Attribute Summary

Attributes inherited from AnyStyle::Feature

#precision

Instance Method Summary collapse

Methods inherited from AnyStyle::Feature

#initialize, #next, #prev, #ratio

Methods included from StringUtils

canonize, count, display_chars, display_width, indent, nnum, page_break?, scrub, strip_html, transliterate

Constructor Details

This class inherits a constructor from AnyStyle::Feature

Instance Method Details

#observe(token, alpha: token, **opts) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/anystyle/feature/keyword.rb', line 4

def observe(token, alpha: token, **opts)
  case token
  when '&'
    :and
  else
    case alpha
    when /^ed(s|itors?|ited?|iteurs?)?$/i,
         /^(hg|hrsg|herausgeber)$/i,
         /^(compilador)$/i,
         //
      :editor
    when /著|撰/,
      :author
    when /^trans(l(ated|ators?|ation))?$/i,
         /^übers(etz(t|ung))?$/i,
         /^trad(uction|ucteurs?|uit)?$/i,
         //
      :translator
    when /^(dissertation|thesis)$/i
      :thesis
    when /^(proceedings|conference|meeting|transactions|communications|seminar|symposi(on|um))/i
      :proceedings
    when /^(Journal|Zeitschrift|Quarterly|Magazine?|Times|Rev(iew|vue)?|Bulletin|News|Week|Gazett[ea])/
      :journal
    when /^in$/i, /收入/
      :in
    when /^([AaUu]nd|y|e)$/
      :and
    when /^(etal|others)$/
      :etal
    when /^(pp?|pages?|S(eiten?)?|ff?)$/
      :page
    when /^(vol(ume)?s?|iss(ue)?|n[or]?|number|fasc(icle|icule)?|suppl(ement)?|j(ahrgan)?g|heft)$/i
      :volume
    when /^(ser(ies?)?|reihe|[ck]oll(e[ck]tion))$/i
      :series
    when /^patent$/i
      :patent
    when /^report$/i
      :report
    when /^(edn|edition|expanded|rev(ised)?|p?reprint(ed)?|illustrated)$/i,
      /^editio|aucta$/i
      /^(aufl(age)?|\p{Alpha}*ausg(abe)?)$/i
      :edition
    when /^(nd|date|spring|s[uo]mmer|autumn|fall|winter|frühling|herbst)$/i,
         /^(jan(uary?)?|feb(ruary?)?|mar(ch|z)?|apr(il)?|ma[yi]|jun[ei]?)$/,
         /^(jul[yi]?|aug(ust)?|sep(tember)?|o[ck]t(ober)?|nov(ember)?|de[cz](ember)?)$/i,
         //
      :date
    when /^(doi|url)/i
      :locator
    when /^(pmid|pmcid)/i
      :pubmed
    when /^(arxiv)/i
      :arxiv
    when /^(retrieved|retirado|accessed|ab(ruf|gerufen))$/i
      :accessed
    when /^[ILXVMCD]{2,}$/
      :roman
    else
      :none
    end
  end
end