Class: LLT::Review::Treebank::Postag

Inherits:
Object
  • Object
show all
Defined in:
lib/llt/review/treebank/postag.rb

Constant Summary collapse

POSTAG_SCHEMA =

All these constants cannot stay. Hardcoding the meaning of every postag datapoint is a no-go.

%i{
  part_of_speech person number tense
  mood voice gender case degree
}
PLURALIZED_POSTAG_SCHEMA =
%i{
  parts_of_speech persons numbers tenses
  moods voices genders cases degrees
}
CONTAINER_TABLE =
PLURALIZED_POSTAG_SCHEMA.zip(POSTAG_SCHEMA)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(postag) ⇒ Postag

Returns a new instance of Postag.



6
7
8
9
# File 'lib/llt/review/treebank/postag.rb', line 6

def initialize(postag)
  @id = :postag
  @postag = postag
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/llt/review/treebank/postag.rb', line 4

def id
  @id
end

Instance Method Details

#add_datapoints_container(data) ⇒ Object



56
57
58
59
60
# File 'lib/llt/review/treebank/postag.rb', line 56

def add_datapoints_container(data)
  CONTAINER_TABLE.each do |pl, sg|
    data.add(Report::Generic.new(pl, 0, sg))
  end
end

#analysisObject



40
41
42
43
44
# File 'lib/llt/review/treebank/postag.rb', line 40

def analysis
  @analysis ||= begin
    Hash[POSTAG_SCHEMA.zip(@postag.each_char)]
  end
end

#datapointsObject



46
47
48
# File 'lib/llt/review/treebank/postag.rb', line 46

def datapoints
  POSTAG_SCHEMA.size
end

#reportObject

A little violating… move this to Datapoints



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/llt/review/treebank/postag.rb', line 16

def report
  @report ||= begin
    # Questionable what the total numbers of datapoints should be.
    data = Report::Datapoints.new(@postag.size)
    add_datapoints_container(data)
    data.each_with_index do |(_, container), i|
      rtr = container.reports_to_request
      val = @postag[i]
      container.add(Report::Postag::Datapoint.new(rtr, val))
      container.increment
    end
    data
  end
end

#to_sObject



11
12
13
# File 'lib/llt/review/treebank/postag.rb', line 11

def to_s
  @postag
end