Class: TM::Article

Inherits:
Object
  • Object
show all
Defined in:
lib/nysol/article.rb

Overview

記事を表すクラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Article

Returns a new instance of Article.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/nysol/article.rb', line 17

def initialize(xml)
	xmlArticle=xml.elements['article']
	@sentences = []
	@dummy     = TM::Sentence.new(nil,self)
	if xmlArticle==nil
		@id=nil
	else
		@id        = xmlArticle.attribute("id").to_s
		@date      = xmlArticle.attribute("date").to_s
		@page      = xmlArticle.attribute("page").to_s
		xmlArticle.elements.each("sentence"){|xmlSentence|
			sentences << TM::Sentence.new(xmlSentence,self)
		}
	end
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



12
13
14
# File 'lib/nysol/article.rb', line 12

def date
  @date
end

#dummyObject (readonly)

Returns the value of attribute dummy.



14
15
16
# File 'lib/nysol/article.rb', line 14

def dummy
  @dummy
end

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/nysol/article.rb', line 11

def id
  @id
end

#pageObject (readonly)

Returns the value of attribute page.



13
14
15
# File 'lib/nysol/article.rb', line 13

def page
  @page
end

#sentencesObject (readonly)

Returns the value of attribute sentences.



15
16
17
# File 'lib/nysol/article.rb', line 15

def sentences
  @sentences
end

Instance Method Details

#caseFrameObject



62
63
64
65
66
67
68
69
# File 'lib/nysol/article.rb', line 62

def caseFrame()
	caseFrames = []
	@sentences.each{|sentence|
		cfs=sentence.caseFrame()
		caseFrames.concat(cfs) if cfs
	}
	return caseFrames
end

#entryCsvout(fp) ⇒ Object



56
57
58
59
60
# File 'lib/nysol/article.rb', line 56

def entryCsvout(fp)
	@sentences.each{|sentence|
		sentence.entryCsvout(fp)
	}
end

#phraseCsvout(fp) ⇒ Object



44
45
46
47
48
# File 'lib/nysol/article.rb', line 44

def phraseCsvout(fp)
	@sentences.each{|sentence|
		sentence.phraseCsvout(fp)
	}
end

#phraseEntryCsvout(fp) ⇒ Object



50
51
52
53
54
# File 'lib/nysol/article.rb', line 50

def phraseEntryCsvout(fp)
	@sentences.each{|sentence|
		sentence.phraseEntryCsvout(fp)
	}
end

#show(simple = false, fp = STDERR) ⇒ Object



71
72
73
74
75
76
# File 'lib/nysol/article.rb', line 71

def show(simple=false,fp=STDERR)
	fp.puts "Article @id=#{@id}"
	sentences.each{|sentence|
		sentence.show(simple,fp)
	}
end

#sizeObject

登録されているsentenceの数を返す



34
35
36
# File 'lib/nysol/article.rb', line 34

def size
	return sentences.size
end

#tokenCsvout(fp) ⇒ Object



38
39
40
41
42
# File 'lib/nysol/article.rb', line 38

def tokenCsvout(fp)
	@sentences.each{|sentence|
		sentence.tokenCsvout(fp)
	}
end