def parse(text, constraints={})
      if text.nil?
        raise ArgumentError.new 'Text to parse cannot be nil'
      elsif constraints[:boundary_constraints]
        if !(constraints[:boundary_constraints].is_a?(Regexp) ||
             constraints[:boundary_constraints].is_a?(String))
          raise ArgumentError.new 'boundary constraints must be a Regexp or String'
        end
      elsif constraints[:feature_constraints] && !constraints[:feature_constraints].is_a?(Hash)
        raise ArgumentError.new 'feature constraints must be a Hash'
      elsif @options[:partial] && !text.end_with?("\n")
        raise ArgumentError.new 'partial parsing requires new-line char at end of text'
      end

      if block_given?
        @parse_tonodes.call(text, constraints).each {|n| yield n }
      else
        @parse_tostr.call(text, constraints)
      end
    end
def parse(text, constraints={})
      if text.nil?
        raise ArgumentError.new 'Text to parse cannot be nil'
      elsif constraints[:boundary_constraints]
        if !(constraints[:boundary_constraints].is_a?(Regexp) ||
             constraints[:boundary_constraints].is_a?(String))
          raise ArgumentError.new 'boundary constraints must be a Regexp or String'
        end
      elsif constraints[:feature_constraints] && !constraints[:feature_constraints].is_a?(Hash)
        raise ArgumentError.new 'feature constraints must be a Hash'
      elsif @options[:partial] && !text.end_with?("\n")
        raise ArgumentError.new 'partial parsing requires new-line char at end of text'
      end

      if block_given?
        @parse_tonodes.call(text, constraints).each {|n| yield n }
      else
        @parse_tostr.call(text, constraints)
      end
    end
Initializes the wrapped Tagger instance with the given `options`.

 Options supported are:

 - :rcfile --  resource file
 - :dicdir --  system dicdir
 - :userdic --  user dictionary
 - :lattice_level --  lattice information level (DEPRECATED)
 - :output_format_type --  output format type (wakati, chasen, yomi, etc.)
 - :all_morphs --  output all morphs (default false)
 - :nbest --  output N best results (integer, default 1), requires lattice level >= 1
 - :partial --  partial parsing mode
 - :marginal --  output marginal probability
 - :max_grouping_size --  maximum grouping size for unknown words (default 24)
 - :node_format --  user-defined node format
 - :unk_format --  user-defined unknown node format
 - :bos_format --  user-defined beginning-of-sentence format
 - :eos_format --  user-defined end-of-sentence format
 - :eon_format --  user-defined end-of-NBest format
 - :unk_feature --  feature for unknown word
 - :input_buffer_size -- set input buffer size (default 8192)
 - :allocate_sentence -- allocate new memory for input sentence
 - :theta --  temperature parameter theta (float, default 0.75)
 - :cost_factor --  cost factor (integer, default 700)

 <p>MeCab command-line arguments (-F) or long (--node-format) may be used in
 addition to Ruby-style hashs</p>
 <i>Use single-quotes to preserve format options that contain escape chars.</i><br/>
 e.g.<br/>

     nm = Natto::MeCab.new(node_format: '%m¥t%f[7]¥n')
     => #<Natto::MeCab:0x00000803503ee8                                 \
          @model=#<FFI::Pointer address=0x00000802b6d9c0>,              \
          @tagger=#<FFI::Pointer address=0x00000802ad3ec0>,             \
          @lattice=#<FFI::Pointer address=0x000008035f3980>,            \
          @libpath="/usr/local/lib/libmecab.so",                        \
          @options={:node_format=>"%m¥t%f[7]¥n"},                       \
          @dicts=[#<Natto::DictionaryInfo:0x000008035038f8              \
                    @filepath="/usr/local/lib/mecab/dic/ipadic/sys.dic" \
                    charset=utf8,                                       \
                    type=0>]                                            \
          @version=0.996>

     puts nm.parse('才能とは求める人間に与えられるものではない。')
     才能    サイノウ
     と      ト
     は      ハ
     求      モトメル
     人間    ニンゲン
     に      ニ
     与え    アタエ
     られる  ラレル
     もの    モノ
     で      デ
     は      ハ
     ない    ナイ
     。      。
     EOS
 @param options [Hash, String] the MeCab options
 @raise [MeCabError] if MeCab cannot be initialized with the given `options`
 Parses the given `text`, returning the MeCab output as a single string.
 If a block is passed to this method, then node parsing will be used
 and each node yielded to the given block.

 Boundary constraint parsing is available via passing in the
 `boundary_constraints` key in the `options` hash. Boundary constraints
 parsing provides hints to MeCab on where the morpheme boundaries in the
 given `text` are located. `boundary_constraints` value may be either a
 `Regexp` or `String`; please see [String#scan](http://ruby-doc.org/core-2.2.1/String.html#method-i-scan)
 The boundary constraint parsed output will be returned as a single
 string, unless a block is passed to this method for node parsing.

 Feature constraint parsing is available by passing in the
 `feature_constraints` key in the `options` hash. Feature constraints
 parsing provides instructions to MeCab to use the feature indicated
 for any morpheme that is an exact match for the given key.
 `feature_constraints` is a hash mapping a specific morpheme (String)
 to a corresponding feature value (String).
 @param text [String] the Japanese text to parse
 @param constraints [Hash] `boundary_constraints` or `feature_constraints`
 @return [String] parsing result from MeCab
 @raise [MeCabError] if the MeCab Tagger cannot parse the given `text`
 @raise [ArgumentError] if the given string `text` argument is `nil`
 @see MeCabNode