LoginSignup
4
1

More than 5 years have passed since last update.

決算説明資料の頻出単語を出してみる

Last updated at Posted at 2018-12-25

2018年の決算説明資料を形態素解析して頻出単語
を出してみたいと思います。

対象のpdfは以下の4つです。
2018年9月期本決算

2018年9月期3Q

2018年9月期2Q

2018年9月期1Q 

pdfからテキストを抽出する

pdfcandy
というサービスを使って、pdfから.txtファイルに変換を行いました。

形態素解析する

変換したテキストを(手動で)一つのテキストファイルにして、
mecabとrubyを使って、形態素解析を行います。

module My                                                                                       
  class WordCounter                                                              
    MECAB = '/usr/local/bin/mecab'                                               
    NECESSARY_FEATURE = %w/名詞,固有名詞 名詞,一般 名詞,副詞可能 名詞/           
    UNNECESSARY_FEATURE = %w/数 名詞,接尾,記号/                                  

    def initialize                                                               
      @result = Hash.new(0)                                                      
    end                                                                          

    attr_reader :result                                                          

    # mainループ                                                                 
    def count(text)                                                              
      words = split_to_words(text)                                               
      count_up_result(words)                                                     
      self                                                                       
    end                                                                          

    # Mecabで単語に分割し,必要な品詞のみ抽出する                                
    def split_to_words(text)                                                     
      results = IO.popen(MECAB, 'r+') { |mecab|                                  
        mecab.puts(text) 
        mecab.close_write                                                        
        mecab.readlines                                                          
      }                                                                          
      results.map { |result| necessary?(result) ? result.split.first : nil }.compact
    end                                                                          

    # 単語として使うする属性を判断する                                           
    def necessary?(feature)                                                      
      case feature                                                               
      when Regexp.new(NECESSARY_FEATURE.join('|'))                               
        true                                                                     
      when Regexp.new(UNNECESSARY_FEATURE.join('|'))                             
        false                                                                    
      when /名詞/                                                                
        warn feature                                                             
        false                                                                    
      else                                                                       
        false                                                                    
      end                                                                        
    end                                                                          

    # 単語数をカウント                                                           
    def count_up_result(words)                                                   
      words.each do |word|                                                       
        @result[word] += 1                                                       
      end                                                                        
    end                                                                          
  end 

target = File.open("ir_text.txt")                                                    
target_string = target.read                                                      
target.close                                                                     

counter = My::WordCounter.new                                                    
counter.count(target_string)                                                     

result = counter.result.sort_by{ |word,count| -count }                           

result.each { |word,count| puts "#{word} => #{count}" }                                    

(対象外にする品詞のフィルタリングがうまくいかなかったので後日検証します…)

結果

LIFULL => 395
事業 => 186
不動産 => 118
情報 => 102
サービス => 88
売上 => 79
Trovit => 71
Mitula => 68
株 => 66
万 => 66
物件 => 65
サイト => 65
顧客 => 63
株式会社 => 60
運営 => 59
利益 => 57
その他 => 57
海外 => 56
収益 => 53
億 => 52
変更 => 49
会社 => 48
当期 => 47
ARPA => 47
関連 => 46
費 => 46
子会社 => 46
セグメント => 46

この中で社名や「不動産情報サービス」「株式会社」などの
頻出してある種当然の単語を抜くと、

Trovit => 71
Mitula => 68
サイト => 65
顧客 => 63
利益 => 57
海外 => 56
変更 => 49
当期 => 47
ARPA => 47
子会社 => 46

海外事業やARPA(加盟店あたりの売り上げ)の向上に注力する、
ということが改めて読み取れたかと思います。

本来なら時系列での比較や同業他社の比較が
面白い結果が出るはずなのですが
今回はここまでで、また別の機会に試してみたいと思います。

4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1