Class: TM::ParticlePhrase

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chunk, p = nil) ⇒ ParticlePhrase

第2引数がnilの場合,第1引数をChunkと解釈して初期化する。両引数がStringであればword,particleと解釈して初期化する。



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
# File 'lib/nysol/phrase.rb', line 28

def initialize(chunk, p=nil)
  if chunk.class==String then
    @word=chunk
    @particle=p
    @wordClass=nil
  else
    word     = ""
    wordClass= ""
    particle = ""
#puts "ID=====#{chunk.sentence.id}"
    chunk.tokens.each { |token|
#puts "#{token.orgWord} #{token.class2}"
      if token.class2 == "格助詞" or token.class2=="係助詞" then
        particle = token.word
        break
      #elsif token.class1 == "名詞" then # 「評価しない」は、=>「評価は」となってしまう
      else
        if not token.ignoreClass? then
          word += token.orgWord
          wordClass += "#{token.class1}_#{token.class2}:"
        end
      end
    }

#puts "word=#{word}"
    if word!="" and particle!="" then
      particle="が" if particle=="は" or particle=="も"
      @word     = word
      @wordClass= wordClass
      @particle = particle

      @cid      = chunk.id # 2010/11/10追加
    end
  end
end

Instance Attribute Details

#cidObject (readonly)

この格助詞句のchunkID # 2010/11/10追加



21
22
23
# File 'lib/nysol/phrase.rb', line 21

def cid
  @cid
end

#identifiedObject (readonly)

以下iterationで動的に変化するメンバ変数



24
25
26
# File 'lib/nysol/phrase.rb', line 24

def identified
  @identified
end

#particleObject (readonly)

格助詞



19
20
21
# File 'lib/nysol/phrase.rb', line 19

def particle
  @particle
end

#wordObject (readonly)



17
18
19
# File 'lib/nysol/phrase.rb', line 17

def word
  @word
end

#wordClassObject (readonly)

語のclass2



18
19
20
# File 'lib/nysol/phrase.rb', line 18

def wordClass
  @wordClass
end

Instance Method Details

#add(word, particle) ⇒ Object



64
65
66
67
# File 'lib/nysol/phrase.rb', line 64

def add(word, particle)
  @word     = word
  @particle = particle
end

#show(fp = STDERR) ⇒ Object



91
92
93
# File 'lib/nysol/phrase.rb', line 91

def show(fp=STDERR)
  fp.print "<#{@word}:#{@particle}>"
end

#to_sObject



69
70
71
72
# File 'lib/nysol/phrase.rb', line 69

def to_s
  #return @word+@particle
  return "<#{@word}:#{@particle}>"
end

#writeCid(fp) ⇒ Object

2010/11/10追加



87
88
89
# File 'lib/nysol/phrase.rb', line 87

def writeCid(fp)
  fp.print @cid
end

#writeParticle(fp) ⇒ Object



82
83
84
# File 'lib/nysol/phrase.rb', line 82

def writeParticle(fp)
  fp.print @particle
end

#writeWord(fp) ⇒ Object



78
79
80
# File 'lib/nysol/phrase.rb', line 78

def writeWord(fp)
  fp.print @word
end

#writeWordClass(fp) ⇒ Object



74
75
76
# File 'lib/nysol/phrase.rb', line 74

def writeWordClass(fp)
  fp.print @wordClass
end