old_contents: # -*- coding: utf8 -*-
  
  from __future__ import absolute_import
  from __future__ import division, print_function, unicode_literals
  
  import sys
  
  from functools import wraps
  from os.path import dirname, abspath, join, exists
  from ._compat import to_string, to_unicode, string_types
  
  
  def cached_property(getter):
      """
      Decorator that converts a method into memoized property.
      The decorator works as expected only for classes with
      attribute '__dict__' and immutable properties.
      """
      @wraps(getter)
      def decorator(self):
          key = "_cached_property_" + getter.__name__
  
          if not hasattr(self, key):
              setattr(self, key, getter(self))
  
          return getattr(self, key)
  
      return property(decorator)
  
  
  def expand_resource_path(path):
      directory = dirname(sys.modules["sumy"].__file__)
      directory = abspath(directory)
      return join(directory, to_string("data"), to_string(path))
  
  
  def get_stop_words(language):
      path = expand_resource_path("stopwords/%s.txt" % language)
      if not exists(path):
          raise ValueError("Stop-words are not available for language %s." % language)
  
      with open(path, "rb") as file:
          return frozenset(to_unicode(w.rstrip()) for w in file.readlines())
  
  
  class ItemsCount(object):
      def __init__(self, value):
          self._value = value
  
      def __call__(self, sequence):
          if isinstance(self._value, string_types):
              if self._value.endswith("%"):
                  total_count = len(sequence)
                  percentage = int(self._value[:-1])
                  count = total_count*percentage // 100
                  return sequence[:count]
              else:
                  return sequence[:int(self._value)]
          elif isinstance(self._value, int):
              return sequence[:self._value]
          else:
              ValueError("Unsuported value of items count '%s'." % self._value)
  
new_contents: # -*- coding: utf8 -*-
  
  from __future__ import absolute_import
  from __future__ import division, print_function, unicode_literals
  
  import sys
  
  from functools import wraps
  from os.path import dirname, abspath, join, exists
  from ._compat import to_string, to_unicode, string_types
  
  
  def cached_property(getter):
      """
      Decorator that converts a method into memoized property.
      The decorator works as expected only for classes with
      attribute '__dict__' and immutable properties.
      """
      @wraps(getter)
      def decorator(self):
          key = "_cached_property_" + getter.__name__
  
          if not hasattr(self, key):
              setattr(self, key, getter(self))
  
          return getattr(self, key)
  
      return property(decorator)
  
  
  def expand_resource_path(path):
      directory = dirname(sys.modules["sumy"].__file__)
      directory = abspath(directory)
      return join(directory, to_string("data"), to_string(path))
  
  
  def get_stop_words(language):
      path = expand_resource_path("stopwords/%s.txt" % language)
      if not exists(path):
          raise ValueError("Stop-words are not available for language %s." % language)
  
      with open(path, "rb") as file:
          return frozenset(to_unicode(w.rstrip()) for w in file.readlines())
  
  
  class ItemsCount(object):
      def __init__(self, value):
          self._value = value
  
      def __call__(self, sequence):
          if isinstance(self._value, string_types):
              if self._value.endswith("%"):
                  total_count = len(sequence)
                  percentage = int(self._value[:-1])
                  # at least one sentence should be choosen
                  count = max(1, total_count*percentage // 100)
                  return sequence[:count]
              else:
                  return sequence[:int(self._value)]
          elif isinstance(self._value, int):
              return sequence[:self._value]
          else:
              ValueError("Unsuported value of items count '%s'." % self._value)
  
subject: Add to summary at least 1 sentence if possible