text:
"""Lookup operations."""
# pylint: disable=g-bad-name
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import collections
import functools
import six

from tensorflow.python.compat import compat as fwd_compat
from tensorflow.python.eager import context
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.framework import sparse_tensor
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import gen_lookup_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import string_ops
# go/tf-wildcard-import
# pylint: disable=wildcard-import
from tensorflow.python.ops.gen_lookup_ops import *
# pylint: enable=wildcard-import
from tensorflow.python.util import compat
from tensorflow.python.util.deprecation import deprecated
from tensorflow.python.util.tf_export import tf_export

@tf_export("initialize_all_tables")
@deprecated(None, "Use `tf.tables_initializer` instead.")
def initialize_all_tables(name="init_all_tables"):
  """Returns an Op that initializes all tables of the default graph.

  Args:
    name: Optional name for the initialization op.

  Returns:
    An Op that initializes all tables.  Note that if there are
    not tables the returned Op is a NoOp.
  """
  return tables_initializer(name)

@tf_export("initializers.tables_initializer", "tables_initializer")
def tables_initializer(name="init_all_tables"):
  """Returns an Op that initializes all tables of the default graph.

  Args:
    name: Optional name for the initialization op.

  Returns:
    An Op that initializes all tables.  Note that if there are
    not tables the returned Op is a NoOp.
  """
  initializers = ops.get_collection(ops.GraphKeys.TABLE_INITIALIZERS)
  if initializers:
    return control_flow_ops.group(*initializers, name=name)
  return control_flow_ops.no_op(name=name)

def _check_table_dtypes(table, key_dtype, value_dtype):
  """Check that the given key_dtype and value_dtype matches the table dtypes.

  Args:
    table: The table to check types against to.
    key_dtype: The key data type to check.
    value_dtype: The value data type to check.

  Raises:
    TypeError: when 'key_dtype' or 'value_dtype' doesn't match the table data
      types.
  """
  if key_dtype.base_dtype != table.key_dtype:
    raise TypeError("Invalid key dtype, expected %s but got %s." %
                    (table.key_dtype, key_dtype))
  if value_dtype.base_dtype != table.value_dtype:
    raise TypeError("Invalid value dtype, expected %s but got %s." %
                    (table.value_dtype, value_dtype))

class LookupInterface(object):
  """Represent a lookup table that persists across different steps."""

  def __init__(self, key_dtype, value_dtype, name):
    """Construct a lookup table interface.

    Args:
      key_dtype: The table key type.
      value_dtype: The table value type.
      name: A name for the operation (optional).
    """
    self._key_dtype = dtypes.as_dtype(key_dtype)
    self._value_dtype = dtypes.as_dtype(value_dtype)
    self._name = name

  @property
  def key_dtype(self):
    """The table key dtype."""
    return self._key_dtype

  @property
  def value_dtype(self):
    """The table value dtype."""
    return self._value_dtype

  @property
  def name(self):
    """The name of the table."""
    return self._name

  @property
  def init(self):
    """The table initialization op."""
    raise NotImplementedError

  def size(self, name=None):
    """Compute the number of elements in this table."""
    raise NotImplementedError

  def lookup(self, keys, name=None):
    """Looks up `keys` in a table, outputs the corresponding values."""
    raise NotImplementedError

class InitializableLookupTableBase(LookupInterface):
  """Initializable lookup table interface.

  An initializable lookup tables persist across different steps.
  """

  def __init__(self, table_ref, default_value, initializer):
    """Construct a table object from a table reference.

    If requires a table initializer object (subclass of `TableInitializerBase`).
    It provides the table key and value types, as well as the op to initialize
    the table. The caller is responsible to execute the initialization op.

    Args:
      table_ref: The table reference, i.e. the output of the lookup table ops.
      default_value: The value to use if a key is missing in the table.
      initializer: The table initializer to use.
    """
    if context.executing_eagerly():
      name = context.context().scope_name
    else:
      name = table_ref.op.name.split("/")[-1]
    super(InitializableLookupTableBase,
          self).__init__(initializer.key_dtype, initializer.value_dtype,
                         name)
    self._table_ref = table_ref
    self._default_value = ops.convert_to_tensor(
        default_value, dtype=self._value_dtype)
    self._default_value.get_shape().merge_with(tensor_shape.scalar())
    self._init = initializer.initialize(self)

  @property
  def table_ref(self):
    """Get the underlying table reference."""
    return self._table_ref

  @property
  def default_value(self):
    """The default value of the table."""
    return self._default_value

  @property
  def init(self):
    """The table initialization op."""
    return self._init

  def size(self, name=None):
    """Compute the number of elements in this table.

    Args:
      name: A name for the operation (optional).

    Returns:
      A scalar tensor containing the number of elements in this table.
    """
    with ops.name_scope(name, "%s_Size" % self._name,
                        [self._table_ref]) as scope:
      return gen_lookup_ops.lookup_table_size_v2(self._table_ref, name=scope)

  def lookup(self, keys, name=None):
    """Looks up `keys` in a table, outputs the corresponding values.

    The `default_value` is used for keys not present in the table.

    Args:
      keys: Keys to look up. May be either a `SparseTensor` or dense `Tensor`.
      name: A name for the operation (optional).

    Returns:
      A `SparseTensor` if keys are sparse, otherwise a dense `Tensor`.

    Raises:
      TypeError: when `keys` or `default_value` doesn't match the table data
        types.
    """
    key_tensor = keys
    if isinstance(keys, sparse_tensor.SparseTensor):
      key_tensor = keys.values

    if keys.dtype.base_dtype != self._key_dtype:
      raise TypeError("Signature mismatch. Keys must be dtype %s, got %s." %
                      (self._key_dtype, keys.dtype))

    with ops.name_scope(name, "%s_Lookup" % self._name,
                        (self._table_ref, key_tensor,
                         self._default_value)) as scope:
      values = gen_lookup_ops.lookup_table_find_v2(
          self._table_ref, key_tensor, self._default_value, name=scope)

    values.set_shape(key_tensor.get_shape())
    if isinstance(keys, sparse_tensor.SparseTensor):
      return sparse_tensor.SparseTensor(keys.indices, values, keys.dense_shape)
    else:
      return values

class HashTable(InitializableLookupTableBase):
  """A generic hash table implementation.

  Example usage:

  ```python
  table = tf.HashTable(
      tf.KeyValueTensorInitializer(keys, values), -1)
  out = table.lookup(input_tensor)
  table.init.run()
  print(out.eval())
  ```
  """

  def __init__(self, initializer, default_value, shared_name=None, name=None):
    """Creates a non-initialized `HashTable` object.

    Creates a table, the type of its keys and values are specified by the
    initializer.
    Before using the table you will have to initialize it. After initialization
    the table will be immutable.

    Args:
      initializer: The table initializer to use. See `HashTable` kernel for
        supported key and value types.
      default_value: The value to use if a key is missing in the table.
      shared_name: If non-empty, this table will be shared under
        the given name across multiple sessions.
      name: A name for the operation (optional).

    Returns:
      A `HashTable` object.
    """
    with ops.name_scope(name, "hash_table", (initializer,
                                             default_value)) as scope:
      table_ref = gen_lookup_ops.hash_table_v2(
          shared_name=shared_name,
          key_dtype=initializer.key_dtype,
          value_dtype=initializer.value_dtype,
          name=scope)

      super(HashTable, self).__init__(table_ref, default_value, initializer)
      self._value_shape = self._default_value.get_shape()

  def export(self, name=None):
    """Returns tensors of all keys and values in the table.

    Args:
      name: A name for the operation (optional).

    Returns:
      A pair of tensors with the first tensor containing all keys and the
        second tensors containing all values in the table.
    """
    with ops.name_scope(name, "%s_Export" % self._name,
                        [self._table_ref]) as name:
      with ops.colocate_with(self._table_ref):
        exported_keys, exported_values = gen_lookup_ops.lookup_table_export_v2(
            self._table_ref, self._key_dtype, self._value_dtype, name=name)

    exported_values.set_shape(exported_keys.get_shape().concatenate(
        self._value_shape))
    return exported_keys, exported_values

class TableInitializerBase(object):
  """Base class for lookup table initializers."""

  def __init__(self, key_dtype, value_dtype):
    """Construct a table initializer object.

    Args:
      key_dtype: Type of the table keys.
      value_dtype: Type of the table values.
    """
    self._key_dtype = dtypes.as_dtype(key_dtype)
    self._value_dtype = dtypes.as_dtype(value_dtype)

  @property
  def key_dtype(self):
    """The expected table key dtype."""
    return self._key_dtype

  @property
  def value_dtype(self):
    """The expected table value dtype."""
    return self._value_dtype

  def initialize(self, table):
    """Returns the table initialization op."""
    raise NotImplementedError

class KeyValueTensorInitializer(TableInitializerBase):
  """Table initializers given `keys` and `values` tensors."""

  def __init__(self, keys, values, key_dtype=None, value_dtype=None, name=None):
    """Constructs a table initializer object based on keys and values tensors.

    Args:
      keys: The tensor for the keys.
      values: The tensor for the values.
      key_dtype: The `keys` data type. Used when `keys` is a python array.
      value_dtype: The `values` data type. Used when `values` is a python array.
      name: A name for the operation (optional).
    """
    with ops.name_scope(name, "key_value_init", [keys, values]) as scope:
      self._keys = ops.convert_to_tensor(keys, dtype=key_dtype, name="keys")
      self._values = ops.convert_to_tensor(
          values, dtype=value_dtype, name="values")
      self._name = scope

    super(KeyValueTensorInitializer, self).__init__(self._keys.dtype,
                                                    self._values.dtype)

  def initialize(self, table):
    """Initializes the given `table` with `keys` and `values` tensors.

    Args:
      table: The table to initialize.

    Returns:
      The operation that initializes the table.

    Raises:
      TypeError: when the keys and values data types do not match the table
      key and value data types.
    """
    _check_table_dtypes(table, self._keys.dtype, self._values.dtype)
    with ops.name_scope(
        self._name, values=(table.table_ref, self._keys,
                            self._values)) as scope:
      if context.executing_eagerly():
        # Ensure a unique name when eager execution is enabled to avoid spurious
        # sharing issues.
        scope += str(ops.uid())
      if fwd_compat.forward_compatible(2018, 9, 19):
        init_op = gen_lookup_ops.lookup_table_import_v2(
            table.table_ref, self._keys, self._values, name=scope)
      else:
        # To maintain forward compatibiltiy, use the old implementation.
        init_op = gen_lookup_ops.initialize_table_v2(
            table.table_ref, self._keys, self._values, name=scope)
    ops.add_to_collection(ops.GraphKeys.TABLE_INITIALIZERS, init_op)
    return init_op

class TextFileIndex(object):
  WHOLE_LINE = -2
  LINE_NUMBER = -1

class TextFileInitializer(TableInitializerBase):
  """Table initializers from a text file.

  This initializer assigns one entry in the table for each line in the file.

  The key and value type of the table to initialize is given by `key_dtype` and
  `value_dtype`.

  The key and value content to get from each line is specified by
  the `key_index` and `value_index`.

  * `TextFileIndex.LINE_NUMBER` means use the line number starting from zero,
    expects data type int64.
  * `TextFileIndex.WHOLE_LINE` means use the whole line content, expects data
    type string.
  * A value `>=0` means use the index (starting at zero) of the split line based
      on `delimiter`.

  For example if we have a file with the following content:

  ```
  emerson 10
  lake 20
  palmer 30
  ```

  The following snippet initializes a table with the first column as keys and
  second column as values:

  * `emerson -> 10`
  * `lake -> 20`
  * `palmer -> 30`

  ```python
  table = tf.lookup.HashTable(tf.lookup.TextFileInitializer(
      "test.txt", tf.string, 0, tf.int64, 1, delimiter=" "), -1)
  ...
  table.init.run()
  ```

  Similarly to initialize the whole line as keys and the line number as values.

  * `emerson 10 -> 0`
  * `lake 20 -> 1`
  * `palmer 30 -> 2`

  ```python
  table = tf.lookup.HashTable(tf.lookup.TextFileInitializer(
      "test.txt", tf.string, tf.lookup.TextFileIndex.WHOLE_LINE,
      tf.int64, tf.lookup.TextFileIndex.LINE_NUMBER, delimiter=" "), -1)
  ...
  table.init.run()
  ```
  """

  def __init__(self,
               filename,
               key_dtype,
               key_index,
               value_dtype,
               value_index,
               vocab_size=None,
               delimiter="\t",
               name=None):
    """Constructs a table initializer object to populate from a text file.

    It generates one key-value pair per line. The type of table key and
    value are specified by `key_dtype` and `value_dtype`, respectively.
    Similarly the content of the key and value are specified by the key_index
    and value_index.

    - TextFileIndex.LINE_NUMBER means use the line number starting from zero,
      expects data type int64.
    - TextFileIndex.WHOLE_LINE means use the whole line content, expects data
      type string.
    - A value >=0 means use the index (starting at zero) of the split line based
      on `delimiter`.

    Args:
      filename: The filename of the text file to be used for initialization.
        The path must be accessible from wherever the graph is initialized
        (eg. trainer or eval workers). The filename may be a scalar `Tensor`.
      key_dtype: The `key` data type.
      key_index: the index that represents information of a line to get the
        table 'key' values from.
      value_dtype: The `value` data type.
      value_index: the index that represents information of a line to get the
        table 'value' values from.'
      vocab_size: The number of elements in the file, if known.
      delimiter: The delimiter to separate fields in a line.
      name: A name for the operation (optional).

    Raises:
      ValueError: when the filename is empty, or when the table key and value
      data types do not match the expected data types.
    """
    if not isinstance(filename, ops.Tensor) and not filename:
      raise ValueError("Filename required for %s." % name)

    key_dtype = dtypes.as_dtype(key_dtype)
    value_dtype = dtypes.as_dtype(value_dtype)

    if key_index < -2:
      raise ValueError("Invalid key index %s." % (key_index))

    if key_index == TextFileIndex.LINE_NUMBER and key_dtype != dtypes.int64:
      raise ValueError("Signature mismatch. Keys must be dtype %s, got %s." %
                       (dtypes.int64, key_dtype))
    if ((key_index == TextFileIndex.WHOLE_LINE) and
        (not key_dtype.is_integer) and (key_dtype != dtypes.string)):
      raise ValueError(
          "Signature mismatch. Keys must be integer or string, got %s." %
          key_dtype)
    if value_index < -2:
      raise ValueError("Invalid value index %s." % (value_index))

    if value_index == TextFileIndex.LINE_NUMBER and value_dtype != dtypes.int64:
      raise ValueError("Signature mismatch. Values must be dtype %s, got %s." %
                       (dtypes.int64, value_dtype))
    if value_index == TextFileIndex.WHOLE_LINE and value_dtype != dtypes.string:
      raise ValueError("Signature mismatch. Values must be dtype %s, got %s." %
                       (dtypes.string, value_dtype))

    if (vocab_size is not None) and (vocab_size <= 0):
      raise ValueError("Invalid vocab_size %s." % vocab_size)

    self._filename = filename
    self._key_index = key_index
    self._value_index = value_index
    self._vocab_size = vocab_size
    self._delimiter = delimiter
    self._name = name

    super(TextFileInitializer, self).__init__(key_dtype, value_dtype)

  def initialize(self, table):
    """Initializes the table from a text file.

    Args:
      table: The table to be initialized.

    Returns:
      The operation that initializes the table.

    Raises:
      TypeError: when the keys and values data types do not match the table
      key and value data types.
    """
    _check_table_dtypes(table, self.key_dtype, self.value_dtype)
    with ops.name_scope(self._name, "text_file_init",
                        (table.table_ref,)) as scope:
      filename = ops.convert_to_tensor(
          self._filename, dtypes.string, name="asset_filepath")
      init_op = gen_lookup_ops.initialize_table_from_text_file_v2(
          table.table_ref,
          filename,
          self._key_index,
          self._value_index,
          -1 if self._vocab_size is None else self._vocab_size,
          self._delimiter,
          name=scope)
    ops.add_to_collection(ops.GraphKeys.TABLE_INITIALIZERS, init_op)
    # If the filename tensor is anything other than a string constant (e.g., if
    # it is a placeholder) then it does not make sense to track it as an asset.
    if not context.executing_eagerly() and constant_op.is_constant(filename):
      ops.add_to_collection(ops.GraphKeys.ASSET_FILEPATHS, filename)
    return init_op

class TextFileStringTableInitializer(TextFileInitializer):
  """Table initializer for `int64` IDs to string tables from a text file."""

  def __init__(self,
               filename,
               key_column_index=TextFileIndex.LINE_NUMBER,
               value_column_index=TextFileIndex.WHOLE_LINE,
               vocab_size=None,
               delimiter="\t",
               name="text_file_string_table_init"):
    """Constructs an initializer for an id-to-string table from a text file.

    It populates a table that its key and value types are int64 and string,
    respectively. It generates one key-value pair per line.
    The content of the key and value are specified by `key_column_index`
    and `value_column_index`.

    - TextFileIndex.LINE_NUMBER means use the line number starting from zero,
      expects data type int64.
    - TextFileIndex.WHOLE_LINE means use the whole line content, expects data
      type string.
    - A value >=0 means use the index (starting at zero) of the split line based
      on `delimiter`.

    Args:
      filename: The filename of the text file to be used for initialization.
        The path must be accessible from wherever the graph is initialized
        (eg. trainer or eval workers). The filename may be a scalar `Tensor`.
      key_column_index: The column index from the text file to get the keys
        from. The default is to use the line number, starting from zero.
      value_column_index: The column index from the text file to get the
        values from. The default is to use the whole line content.
      vocab_size: The number of elements in the file, if known.
      delimiter: The delimiter to separate fields in a line.
      name: Optional name for the op.

    Raises:
      TypeError: when the filename is empty, or when the table key and value
      data types do not match the expected data types.
    """
    super(TextFileStringTableInitializer, self).__init__(
        filename,
        dtypes.int64,
        key_column_index,
        dtypes.string,
        value_column_index,
        vocab_size=vocab_size,
        delimiter=delimiter,
        name=name)

class TextFileIdTableInitializer(TextFileInitializer):
  """Table initializer for string to `int64` IDs tables from a text file."""

  def __init__(self,
               filename,
               key_column_index=TextFileIndex.WHOLE_LINE,
               value_column_index=TextFileIndex.LINE_NUMBER,
               vocab_size=None,
               delimiter="\t",
               name="text_file_id_table_init",
               key_dtype=dtypes.string):
    """Constructs an initializer for an string-to-id table from a text file.

    It populates a table that its key and value types are string and int64,
    respectively. It generates one key-value pair per line.
    The content of the key and value are specified by the key_index
    and value_index.

    - TextFileIndex.LINE_NUMBER means use the line number starting from zero,
      expects data type int64.
    - TextFileIndex.WHOLE_LINE means use the whole line content, expects data
      type string.
    - A value >=0 means use the index (starting at zero) of the split line based
      on `delimiter`.

    Args:
      filename: The filename of the text file to be used for initialization.
        The path must be accessible from wherever the graph is initialized
        (eg. trainer or eval workers). The filename may be a scalar `Tensor`.
      key_column_index: The column index from the text file to get the `key`
        values from. The default is to use the whole line content.
      value_column_index: The column index from the text file to get the `value`
        values from. The default is to use the line number, starting from zero.
      vocab_size: The number of elements in the file, if known.
      delimiter: The delimiter to separate fields in a line.
      name: Optional name for the op.
      key_dtype: The `key` data type.

    Raises:
      TypeError: when the filename is empty, or when the table key and value
      data types do not match the expected data types.
    """
    super(TextFileIdTableInitializer, self).__init__(
        filename,
        key_dtype,
        key_column_index,
        dtypes.int64,
        value_column_index,
        vocab_size=vocab_size,
        delimiter=delimiter,
        name=name)

class HasherSpec(collections.namedtuple("HasherSpec", ["hasher", "key"])):
  """A structure for the spec of the hashing function to use for hash buckets.

  `hasher` is the name of the hashing function to use (eg. "fasthash",
  "stronghash").
  `key` is optional and specify the key to use for the hash function if
  supported, currently only used by a strong hash.

  Fields:
    hasher: The hasher name to use.
    key: The key to be used by the hashing function, if required.
  """
  __slots__ = ()

FastHashSpec = HasherSpec("fasthash", None)  # pylint: disable=invalid-name

class StrongHashSpec(HasherSpec):
  """A structure to specify a key of the strong keyed hash spec.

  The strong hash requires a `key`, which is a list of 2 unsigned integer
  numbers. These should be non-zero; random numbers generated from random.org
  would be a fine choice.

  Fields:
    key: The key to be used by the keyed hashing function.
  """
  __slots__ = ()

  def __new__(cls, key):
    if len(key) != 2:
      raise ValueError("key must have size 2, got %s." % len(key))

    if not isinstance(key[0], compat.integral_types) or not isinstance(
        key[1], compat.integral_types):
      raise TypeError("Invalid key %s. Must be unsigned integer values." % key)

    return super(cls, StrongHashSpec).__new__(cls, "stronghash", key)

def _as_string(tensor):
  if dtypes.string == tensor.dtype.base_dtype:
    return tensor
  return string_ops.as_string(tensor)

class IdTableWithHashBuckets(LookupInterface):
  """String to Id table wrapper that assigns out-of-vocabulary keys to buckets.

  For example, if an instance of `IdTableWithHashBuckets` is initialized with a
  string-to-id table that maps:

  * `emerson -> 0`
  * `lake -> 1`
  * `palmer -> 2`

  The `IdTableWithHashBuckets` object will performs the following mapping:

  * `emerson -> 0`
  * `lake -> 1`
  * `palmer -> 2`
  * `<other term> -> bucket_id`, where bucket_id will be between `3` and
  `3 + num_oov_buckets - 1`, calculated by:
  `hash(<term>) % num_oov_buckets + vocab_size`

  If input_tensor is `["emerson", "lake", "palmer", "king", "crimson"]`,
  the lookup result is `[0, 1, 2, 4, 7]`.

  If `table` is None, only out-of-vocabulary buckets are used.

  Example usage:

  ```python
  num_oov_buckets = 3
  input_tensor = tf.constant(["emerson", "lake", "palmer", "king", "crimnson"])
  table = tf.IdTableWithHashBuckets(
      tf.HashTable(tf.TextFileIdTableInitializer(filename), default_value),
      num_oov_buckets)
  out = table.lookup(input_tensor).
  table.init.run()
  print(out.eval())
  ```

  The hash function used for generating out-of-vocabulary buckets ID is handled
  by `hasher_spec`.
  """

  def __init__(self,
               table,
               num_oov_buckets,
               hasher_spec=FastHashSpec,
               name=None,
               key_dtype=None):
    """Construct a `IdTableWithHashBuckets` object.

    Args:
      table: Table that maps `tf.string` or `tf.int64` keys to `tf.int64` ids.
      num_oov_buckets: Number of buckets to use for out-of-vocabulary keys.
      hasher_spec: A `HasherSpec` to specify the hash function to use for
        assignation of out-of-vocabulary buckets  (optional).
      name: A name for the operation (optional).
      key_dtype: Data type of keys passed to `lookup`. Defaults to
        `table.key_dtype` if `table` is specified, otherwise `tf.string`.
        Must be string or integer, and must be castable to `table.key_dtype`.

    Raises:
      ValueError: when `table` in None and `num_oov_buckets` is not positive.
      TypeError: when `hasher_spec` is invalid.
    """
    # If a name ends with a '/' it is a "name scope", remove all trailing '/'
    # characters to use as table name.
    if name:
      name = name.rstrip("/")
    if table:
      if key_dtype is None:
        key_dtype = table.key_dtype
      supported_table_key_dtypes = (dtypes.int64, dtypes.string)
      if table.key_dtype not in supported_table_key_dtypes:
        raise TypeError("Invalid key dtype, expected one of %s, but got %s." %
                        (supported_table_key_dtypes, key_dtype))
      if table.key_dtype.is_integer != key_dtype.is_integer:
        raise TypeError("Invalid key dtype, expected %s but got %s." %
                        ("integer" if key_dtype.is_integer else "non-integer",
                         table.key_dtype))
      if table.value_dtype != dtypes.int64:
        raise TypeError("Invalid value dtype, expected %s but got %s." %
                        (dtypes.int64, table.value_dtype))
      self._table = table
      name = name or self._table.name
    else:
      if num_oov_buckets <= 0:
        raise ValueError("oov_buckets must be > 0 if no table is supplied.")
      key_dtype = dtypes.string if key_dtype is None else key_dtype
      self._table = None
      name = name or "hash_bucket"
    if (not key_dtype.is_integer) and (dtypes.string != key_dtype):
      raise TypeError(
          "Invalid key_dtype, expected integer or string, got %s." % key_dtype)
    self._num_oov_buckets = num_oov_buckets

    if not isinstance(hasher_spec, HasherSpec):
      raise TypeError(
          "hasher_spec must be of type HasherSpec, got %s" % hasher_spec)
    self._hasher_spec = hasher_spec
    super(IdTableWithHashBuckets, self).__init__(key_dtype, dtypes.int64,
                                                 name.split("/")[-1])

  @property
  def init(self):
    """The table initialization op."""
    if self._table:
      return self._table.init
    with ops.name_scope(None, "init"):
      return control_flow_ops.no_op()

  @property
  def table_ref(self):
    """Returns the table_ref of the underlying table, if one exists.

    Only use the table_ref directly if you know what you are doing. The
    table_ref does not have the "hash bucket" functionality, as that is provided
    by this class.

    One possible use of the table_ref is subtokenization, i.e. ops which
    dynamically decompose tokens into subtokens based on the contents of the
    table_ref.

    Returns:
      the underlying table_ref, or None if there is no underlying table
    """
    if self._table is not None:
      return self._table.table_ref
    return None

  def size(self, name=None):
    """Compute the number of elements in this table."""
    with ops.name_scope(name, "%s_Size" % self.name) as scope:
      if self._table:
        tsize = self._table.size(scope)
      else:
        tsize = ops.convert_to_tensor(0, dtype=dtypes.int64)
      return tsize + self._num_oov_buckets

  def _get_string_to_hash_bucket_fn(self, hasher_spec):
    """Returns the string_to_hash_bucket op to use based on `hasher_spec`."""
    if not isinstance(hasher_spec, HasherSpec):
      raise TypeError("hasher_spec must be of type HasherSpec %s" % hasher_spec)
    if hasher_spec.hasher == "fasthash":
      return string_ops.string_to_hash_bucket_fast
    if hasher_spec.hasher == "legacy":
      return string_ops.string_to_hash_bucket
    if hasher_spec.hasher == "stronghash":
      return functools.partial(
          string_ops.string_to_hash_bucket_strong, key=hasher_spec.key)
    raise ValueError("Unknown hasher %s" % hasher_spec.hasher)

  def lookup(self, keys, name=None):
    """Looks up `keys` in the table, outputs the corresponding values.

    It assigns out-of-vocabulary keys to buckets based in their hashes.

    Args:
      keys: Keys to look up. May be either a `SparseTensor` or dense `Tensor`.
      name: Optional name for the op.

    Returns:
      A `SparseTensor` if keys are sparse, otherwise a dense `Tensor`.

    Raises:
      TypeError: when `keys` doesn't match the table key data type.
    """
    if keys.dtype.base_dtype != self._key_dtype:
      raise TypeError("Signature mismatch. Keys must be dtype %s, got %s." %
                      (self._key_dtype, keys.dtype))
    values = keys
    if isinstance(keys, sparse_tensor.SparseTensor):
      values = keys.values
    if self._table and (self._table.key_dtype.base_dtype == dtypes.int64):
      values = math_ops.to_int64(values)

    if self._num_oov_buckets == 0:
      ids = self._table.lookup(values, name=name)
    else:
      # TODO(yleon): Consider moving this functionality to its own kernel.
      with ops.name_scope(name, "%s_Lookup" % self.name) as scope:
        str_to_hash_bucket = self._get_string_to_hash_bucket_fn(
            self._hasher_spec)
        buckets = str_to_hash_bucket(
            _as_string(values),
            num_buckets=self._num_oov_buckets,
            name="hash_bucket")
        if self._table:
          ids = self._table.lookup(values)
          buckets = math_ops.add(buckets, self._table.size())
          is_id_non_default = math_ops.not_equal(ids, self._table.default_value)
          ids = array_ops.where(is_id_non_default, ids, buckets, name=scope)
        else:
          ids = buckets
    if isinstance(keys, sparse_tensor.SparseTensor):
      return sparse_tensor.SparseTensor(keys.indices, ids, keys.dense_shape)
    return ids

def index_table_from_file(vocabulary_file=None,
                          num_oov_buckets=0,
                          vocab_size=None,
                          default_value=-1,
                          hasher_spec=FastHashSpec,
                          key_dtype=dtypes.string,
                          name=None,
                          key_column_index=TextFileIndex.WHOLE_LINE,
                          value_column_index=TextFileIndex.LINE_NUMBER,
                          delimiter="\t"):
  """Returns a lookup table that converts a string tensor into int64 IDs.

  This operation constructs a lookup table to convert tensor of strings into
  int64 IDs. The mapping can be initialized from a vocabulary file specified in
  `vocabulary_file`, where the whole line is the key and the zero-based line
  number is the ID.

  Any lookup of an out-of-vocabulary token will return a bucket ID based on its
  hash if `num_oov_buckets` is greater than zero. Otherwise it is assigned the
  `default_value`.
  The bucket ID range is
  `[vocabulary size, vocabulary size + num_oov_buckets - 1]`.

  The underlying table must be initialized by calling
  `tf.tables_initializer.run()` or `table.init.run()` once.

  To specify multi-column vocabulary files, use key_column_index and
  value_column_index and delimiter.

  - TextFileIndex.LINE_NUMBER means use the line number starting from zero,
    expects data type int64.
  - TextFileIndex.WHOLE_LINE means use the whole line content, expects data
    type string.
  - A value >=0 means use the index (starting at zero) of the split line based
    on `delimiter`.

  Sample Usages:

  If we have a vocabulary file "test.txt" with the following content:

  ```
  emerson
  lake
  palmer
  ```

  ```python
  features = tf.constant(["emerson", "lake", "and", "palmer"])
  table = tf.lookup.index_table_from_file(
      vocabulary_file="test.txt", num_oov_buckets=1)
  ids = table.lookup(features)
  ...
  tf.tables_initializer().run()

  ids.eval()  ==> [0, 1, 3, 2]  # where 3 is the out-of-vocabulary bucket
  ```

  Args:
    vocabulary_file: The vocabulary filename, may be a constant scalar `Tensor`.
    num_oov_buckets: The number of out-of-vocabulary buckets.
    vocab_size: Number of the elements in the vocabulary, if known.
    default_value: The value to use for out-of-vocabulary feature values.
      Defaults to -1.
    hasher_spec: A `HasherSpec` to specify the hash function to use for
      assignation of out-of-vocabulary buckets.
    key_dtype: The `key` data type.
    name: A name for this op (optional).
    key_column_index: The column index from the text file to get the `key`
      values from. The default is to use the whole line content.
    value_column_index: The column index from the text file to get the `value`
      values from. The default is to use the line number, starting from zero.
    delimiter: The delimiter to separate fields in a line.

  Returns:
    The lookup table to map a `key_dtype` `Tensor` to index `int64` `Tensor`.

  Raises:
    ValueError: If `vocabulary_file` is not set.
    ValueError: If `num_oov_buckets` is negative or `vocab_size` is not greater
      than zero.
  """
  if vocabulary_file is None or (
      isinstance(vocabulary_file, six.string_types) and not vocabulary_file):
    raise ValueError("vocabulary_file must be specified and must not be empty.")
  if num_oov_buckets < 0:
    raise ValueError("num_oov_buckets must be greater or equal than 0, got %d."
                     % num_oov_buckets)
  if vocab_size is not None and vocab_size < 1:
    vocab_file_value = vocabulary_file
    if isinstance(vocabulary_file, ops.Tensor):
      vocab_file_value = tensor_util.constant_value(vocabulary_file) or "?"
    raise ValueError("vocab_size must be greater than 0, got %d. "
                     "vocabulary_file: %s" % (vocab_size, vocab_file_value))
  if (not key_dtype.is_integer) and (dtypes.string != key_dtype.base_dtype):
    raise TypeError("Only integer and string keys are supported.")

  with ops.name_scope(name, "string_to_index") as feat_to_id_scope:
    table = None
    shared_name = ""
    with ops.name_scope(None, "hash_table") as hash_table_scope:
      if vocab_size:
        # Keep the shared_name:
        # <table_type>_<filename>_<vocab_size>_<key_index>_<value_index>
        shared_name = "hash_table_%s_%d_%s_%s" % (vocabulary_file, vocab_size,
                                                  key_column_index,
                                                  value_column_index)
      else:
        # Keep the shared_name
        # <table_type>_<filename>_<key_index>_<value_index>
        shared_name = "hash_table_%s_%s_%s" % (vocabulary_file,
                                               key_column_index,
                                               value_column_index)
      init = TextFileIdTableInitializer(
          vocabulary_file,
          vocab_size=vocab_size,
          key_dtype=dtypes.int64 if key_dtype.is_integer else key_dtype,
          name="table_init",
          key_column_index=key_column_index,
          value_column_index=value_column_index,
          delimiter=delimiter)

      table = HashTable(
          init, default_value, shared_name=shared_name, name=hash_table_scope)
    if num_oov_buckets:
      table = IdTableWithHashBuckets(
          table,
          num_oov_buckets=num_oov_buckets,
          hasher_spec=hasher_spec,
          name=feat_to_id_scope,
          key_dtype=key_dtype)

    return table

def index_table_from_tensor(vocabulary_list,
                            num_oov_buckets=0,
                            default_value=-1,
                            hasher_spec=FastHashSpec,
                            dtype=dtypes.string,
                            name=None):
  """Returns a lookup table that converts a string tensor into int64 IDs.

  This operation constructs a lookup table to convert tensor of strings into
  int64 IDs. The mapping can be initialized from a string `vocabulary_list` 1-D
  tensor where each element is a key and corresponding index within the tensor
  is the value.

  Any lookup of an out-of-vocabulary token will return a bucket ID based on its
  hash if `num_oov_buckets` is greater than zero. Otherwise it is assigned the
  `default_value`. The bucket ID range is
  `[vocabulary list size, vocabulary list size + num_oov_buckets - 1]`.

  The underlying table must be initialized by calling
  `tf.tables_initializer.run()` or `table.init.run()` once.

  Elements in `vocabulary_list` cannot have duplicates, otherwise when executing
  the table initializer op, it will throw a `FailedPreconditionError`.

  Sample Usages:

  ```python
  vocabulary_list = tf.constant(["emerson", "lake", "palmer"])
  table = tf.lookup.index_table_from_tensor(
      vocabulary_list=vocabulary_list, num_oov_buckets=1, default_value=-1)
  features = tf.constant(["emerson", "lake", "and", "palmer"])
  ids = table.lookup(features)
  ...
  tf.tables_initializer().run()

  ids.eval()  ==> [0, 1, 4, 2]
  ```

  Args:
    vocabulary_list: A 1-D `Tensor` that specifies the mapping of keys to
      indices. The type of this object must be castable to `dtype`.
    num_oov_buckets: The number of out-of-vocabulary buckets.
    default_value: The value to use for out-of-vocabulary feature values.
      Defaults to -1.
    hasher_spec: A `HasherSpec` to specify the hash function to use for
      assignment of out-of-vocabulary buckets.
    dtype: The type of values passed to `lookup`. Only string and integers are
      supported.
    name: A name for this op (optional).

  Returns:
    The lookup table to map an input `Tensor` to index `int64` `Tensor`.

  Raises:
    ValueError: If `vocabulary_list` is invalid.
    ValueError: If `num_oov_buckets` is negative.
  """
  if vocabulary_list is None:
    raise ValueError("vocabulary_list must be specified.")

  if num_oov_buckets < 0:
    raise ValueError("num_oov_buckets must be greater or equal than 0, got %d."
                     % num_oov_buckets)

  if (not dtype.is_integer) and (dtypes.string != dtype.base_dtype):
    raise TypeError("Only integer and string keys are supported.")

  with ops.name_scope(name, "string_to_index") as feat_to_id_scope:
    keys = ops.convert_to_tensor(vocabulary_list)
    if keys.dtype.is_integer != dtype.is_integer:
      raise ValueError("Expected %s, got %s." %
                       ("integer"
                        if dtype.is_integer else "non-integer", keys.dtype))
    if (not dtype.is_integer) and (keys.dtype.base_dtype != dtype):
      raise ValueError("Expected %s, got %s." % (dtype, keys.dtype))
    num_elements = array_ops.size(keys)
    values = math_ops.to_int64(math_ops.range(num_elements))

    shared_name = ""
    with ops.name_scope(None, "hash_table") as hash_table_scope:
      if context.executing_eagerly():
        # Ensure a unique name when eager execution is enabled to avoid spurious
        # sharing issues.
        shared_name += str(ops.uid())
      table_keys = math_ops.to_int64(keys) if keys.dtype.is_integer else keys
      init = KeyValueTensorInitializer(
          table_keys,
          values,
          table_keys.dtype.base_dtype,
          dtypes.int64,
          name="table_init")
      table = HashTable(
          init, default_value, shared_name=shared_name, name=hash_table_scope)
    if num_oov_buckets:
      table = IdTableWithHashBuckets(
          table,
          num_oov_buckets=num_oov_buckets,
          hasher_spec=hasher_spec,
          name=feat_to_id_scope,
          key_dtype=dtype)

    return table

def index_to_string_table_from_file(vocabulary_file,
                                    vocab_size=None,
                                    default_value="UNK",
                                    name=None,
                                    key_column_index=TextFileIndex.LINE_NUMBER,
                                    value_column_index=TextFileIndex.WHOLE_LINE,
                                    delimiter="\t"):
  """Returns a lookup table that maps a `Tensor` of indices into strings.

  This operation constructs a lookup table to map int64 indices into string
  values. The table is initialized from a vocabulary file specified in
  `vocabulary_file`, where the whole line is the value and the
  zero-based line number is the index.

  Any input which does not have a corresponding index in the vocabulary file
  (an out-of-vocabulary entry) is assigned the `default_value`

  The underlying table must be initialized by calling
  `tf.tables_initializer.run()` or `table.init.run()` once.

  To specify multi-column vocabulary files, use key_column_index and
  value_column_index and delimiter.

  - TextFileIndex.LINE_NUMBER means use the line number starting from zero,
    expects data type int64.
  - TextFileIndex.WHOLE_LINE means use the whole line content, expects data
    type string.
  - A value >=0 means use the index (starting at zero) of the split line based
    on `delimiter`.

  Sample Usages:

  If we have a vocabulary file "test.txt" with the following content:

  ```
  emerson
  lake
  palmer
  ```

  ```python
  indices = tf.constant([1, 5], tf.int64)
  table = tf.lookup.index_to_string_table_from_file(
      vocabulary_file="test.txt", default_value="UNKNOWN")
  values = table.lookup(indices)
  ...
  tf.tables_initializer().run()

  values.eval() ==> ["lake", "UNKNOWN"]
  ```

  Args:
    vocabulary_file: The vocabulary filename, may be a constant scalar `Tensor`.
    vocab_size: Number of the elements in the vocabulary, if known.
    default_value: The value to use for out-of-vocabulary indices.
    name: A name for this op (optional).
    key_column_index: The column index from the text file to get the `key`
      values from. The default is to use the line number, starting from zero.
    value_column_index: The column index from the text file to get the `value`
      values from. The default is to use the whole line content.
    delimiter: The delimiter to separate fields in a line.

  Returns:
    The lookup table to map a string values associated to a given index `int64`
    `Tensors`.

  Raises:
    ValueError: when `vocabulary_file` is empty.
    ValueError: when `vocab_size` is invalid.
  """
  if vocabulary_file is None or (
      isinstance(vocabulary_file, six.string_types) and not vocabulary_file):
    raise ValueError("vocabulary_file must be specified and must not be empty.")

  if vocab_size is not None and vocab_size < 1:
    raise ValueError("vocab_size must be greater than 0, got %d." % vocab_size)

  with ops.name_scope(name, "index_to_string") as scope:
    shared_name = ""
    if vocab_size:
      # Keep a shared_name
      # <table_type>_<filename>_<vocab_size>_<key_index>_<value_index>
      shared_name = "hash_table_%s_%d_%s_%s" % (vocabulary_file, vocab_size,
                                                key_column_index,
                                                value_column_index)
    else:
      # Keep a shared_name <table_type>_<filename>_<key_index>_<value_index>
      shared_name = "hash_table_%s_%s_%s" % (vocabulary_file, key_column_index,
                                             value_column_index)
    init = TextFileStringTableInitializer(
        vocabulary_file,
        vocab_size=vocab_size,
        name="table_init",
        key_column_index=key_column_index,
        value_column_index=value_column_index,
        delimiter=delimiter)

    # TODO(yleon): Use a more effienct structure.
    return HashTable(init, default_value, shared_name=shared_name, name=scope)

def index_to_string_table_from_tensor(vocabulary_list,
                                      default_value="UNK",
                                      name=None):
  """Returns a lookup table that maps a `Tensor` of indices into strings.

  This operation constructs a lookup table to map int64 indices into string
  values. The mapping is initialized from a string `vocabulary_list` 1-D
  `Tensor` where each element is a value and the corresponding index within the
  tensor is the key.

  Any input which does not have a corresponding index in 'vocabulary_list'
  (an out-of-vocabulary entry) is assigned the `default_value`

  The underlying table must be initialized by calling
  `tf.tables_initializer.run()` or `table.init.run()` once.

  Elements in `vocabulary_list` cannot have duplicates, otherwise when executing
  the table initializer op, it will throw a `FailedPreconditionError`.

  Sample Usages:

  ```python
  vocabulary_list = tf.constant(["emerson", "lake", "palmer"])
  indices = tf.constant([1, 5], tf.int64)
  table = tf.lookup.index_to_string_table_from_tensor(
      vocabulary_list, default_value="UNKNOWN")
  values = table.lookup(indices)
  ...
  tf.tables_initializer().run()

  values.eval() ==> ["lake", "UNKNOWN"]
  ```

  Args:
    vocabulary_list: A 1-D string `Tensor` that specifies the strings to map
      from indices.
    default_value: The value to use for out-of-vocabulary indices.
    name: A name for this op (optional).

  Returns:
    The lookup table to map a string values associated to a given index `int64`
    `Tensors`.

  Raises:
    ValueError: when `vocabulary_list` is not set.
  """

  if vocabulary_list is None:
    raise ValueError("vocabulary_list must be specified.")

  with ops.name_scope(name, "index_to_string") as scope:
    vocabulary_list = ops.convert_to_tensor(vocabulary_list, dtypes.string)
    num_elements = array_ops.size(vocabulary_list)
    keys = math_ops.to_int64(math_ops.range(num_elements))

    shared_name = ""
    init = KeyValueTensorInitializer(
        keys, vocabulary_list, dtypes.int64, dtypes.string, name="table_init")
    # TODO(yleon): Use a more effienct structure.
    return HashTable(init, default_value, shared_name=shared_name, name=scope)

ops.NotDifferentiable("LookupTableFind")
ops.NotDifferentiable("LookupTableFindV2")
ops.NotDifferentiable("LookupTableInsert")
ops.NotDifferentiable("LookupTableInsertV2")
ops.NotDifferentiable("LookupTableSize")
ops.NotDifferentiable("LookupTableSizeV2")
ops.NotDifferentiable("HashTable")
ops.NotDifferentiable("HashTableV2")
ops.NotDifferentiable("InitializeTable")
ops.NotDifferentiable("InitializeTableV2")
ops.NotDifferentiable("InitializeTableFromTextFile")
ops.NotDifferentiable("InitializeTableFromTextFileV2")
ops.NotDifferentiable("MutableDenseHashTable")
ops.NotDifferentiable("MutableDenseHashTableV2")
ops.NotDifferentiable("MutableHashTable")
ops.NotDifferentiable("MutableHashTableV2")
ops.NotDifferentiable("MutableHashTableOfTensors")
ops.NotDifferentiable("MutableHashTableOfTensorsV2")


text:
const merge = require('merge');

let userConfig;

try {
  userConfig = require('./userConfig.js'); // eslint-disable-line global-require, import/no-unresolved
} catch (ex) {
  userConfig = {};
}

const config = {
  server: {
    port: 8080,
  },
  mailGun: {
    apiKey: '',
    domain: '',
  },
  email: {
    noReplyAdress: 'no-reply@multicora.com',
    defaultFrom: 'no-reply@multicora.com',
    defaultSubject: 'LMS',
  },
  defaultDomain: null,
};

module.exports = merge(config, userConfig);

redpajama_set_name: RedPajamaGithub


text:
layout: page
title: Alexander - Jimenez Wedding
date: 2016-05-24
author: Justin Terry
tags: weekly links, java
status: published
summary: Mauris varius vel nunc id ultricies.
banner: images/banner/office-01.jpg
booking:
  startDate: 02/23/2016
  endDate: 02/26/2016
  ctyhocn: MFEMSHX
  groupCode: AJW
published: true
---
Fusce vestibulum, odio eget aliquam lobortis, neque nisl iaculis lacus, at convallis dolor est ac massa. Phasellus magna lacus, malesuada vel mi a, mollis pulvinar mauris. Ut est nisl, posuere ut tempor et, rutrum vel ligula. Sed efficitur est nulla, et facilisis sapien eleifend iaculis. Ut molestie nisi non sapien interdum suscipit. Pellentesque finibus, mi quis fermentum scelerisque, lorem ligula egestas ante, consectetur mattis tortor ligula eu erat. Duis et purus et massa ultrices facilisis nec nec mauris. Suspendisse eu leo consectetur, ultrices metus non, congue tellus.

* Quisque placerat justo id semper aliquet
* Donec sed odio vel eros scelerisque varius
* Donec quis massa interdum, finibus risus iaculis, viverra magna
* Maecenas porttitor dolor elementum magna mattis laoreet.

Cras lorem nibh, tincidunt ac pulvinar vitae, tincidunt non ligula. Nunc quis consequat metus. Suspendisse vel odio nec dolor vestibulum ornare. Aenean quis consequat elit. Aenean viverra vestibulum pellentesque. Proin quis lectus cursus, facilisis odio eget, mollis dolor. Ut vestibulum elit a purus ornare commodo. Sed iaculis auctor blandit. Maecenas congue condimentum enim et mattis. Integer sed libero tortor.


text:
angular.module('sdk.directives')

.directive('toNumberOnBlur', function($filter,$locale) {
    return {
        require: 'ngModel',
        restrict: 'A',
        link: function(scope, elm, attrs, ctrl) {
            elm.bind('blur', function() {
                var filter = "number";
        		ctrl.$viewValue = $filter(filter)(ctrl.$modelValue);
        		ctrl.$render();
            });

            elm.bind('focus', function() {
        		ctrl.$viewValue = ctrl.$modelValue;
        		ctrl.$render();
            });
        }
    };
});


text:
package basic

/**
* Configuration for service group resource.
*/
type Servicegroup struct {
	/**
	* Name of the service group. Must begin with an ASCII alphabetic or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) characters. Can be changed after the name is created.
	*/
	Servicegroupname string `json:"servicegroupname,omitempty"`
	/**
	* Protocol used to exchange data with the service.
	*/
	Servicetype string `json:"servicetype,omitempty"`
	/**
	* Cache type supported by the cache server.
	*/
	Cachetype string `json:"cachetype,omitempty"`
	/**
	* Integer value that uniquely identifies the traffic domain in which you want to configure the entity. If you do not specify an ID, the entity becomes part of the default traffic domain, which has an ID of 0.
	*/
	Td int `json:"td,omitempty"`
	/**
	* Maximum number of simultaneous open connections for the service group.
	*/
	Maxclient int `json:"maxclient,omitempty"`
	/**
	* Maximum number of requests that can be sent on a persistent connection to the service group.
		Note: Connection requests beyond this value are rejected.
	*/
	Maxreq int `json:"maxreq,omitempty"`
	/**
	* Use the transparent cache redirection virtual server to forward the request to the cache server.
		Note: Do not set this parameter if you set the Cache Type.
	*/
	Cacheable string `json:"cacheable,omitempty"`
	/**
	* Insert the Client IP header in requests forwarded to the service.
	*/
	Cip string `json:"cip,omitempty"`
	/**
	* Name of the HTTP header whose value must be set to the IP address of the client. Used with the Client IP parameter. If client IP insertion is enabled, and the client IP header is not specified, the value of Client IP Header parameter or the value set by the set ns config command is used as client's IP header name.
	*/
	Cipheader string `json:"cipheader,omitempty"`
	/**
	* Use client's IP address as the source IP address when initiating connection to the server. With the NO setting, which is the default, a mapped IP (MIP) address or subnet IP (SNIP) address is used as the source IP address to initiate server side connections.
	*/
	Usip string `json:"usip,omitempty"`
	/**
	* Path monitoring for clustering
	*/
	Pathmonitor string `json:"pathmonitor,omitempty"`
	/**
	* Individual Path monitoring decisions.
	*/
	Pathmonitorindv string `json:"pathmonitorindv,omitempty"`
	/**
	* Use the proxy port as the source port when initiating connections with the server. With the NO setting, the client-side connection port is used as the source port for the server-side connection.
		Note: This parameter is available only when the Use Source IP (USIP) parameter is set to YES.
	*/
	Useproxyport string `json:"useproxyport,omitempty"`
	/**
	* Monitor the health of this service.  Available settings function as follows:
		YES - Send probes to check the health of the service.
		NO - Do not send probes to check the health of the service. With the NO option, the appliance shows the service as UP at all times.
	*/
	Healthmonitor string `json:"healthmonitor,omitempty"`
	/**
	* State of the SureConnect feature for the service group.
	*/
	Sc string `json:"sc,omitempty"`
	/**
	* Enable surge protection for the service group.
	*/
	Sp string `json:"sp,omitempty"`
	/**
	* Enable RTSP session ID mapping for the service group.
	*/
	Rtspsessionidremap string `json:"rtspsessionidremap,omitempty"`
	/**
	* Time, in seconds, after which to terminate an idle client connection.
	*/
	Clttimeout int `json:"clttimeout,omitempty"`
	/**
	* Time, in seconds, after which to terminate an idle server connection.
	*/
	Svrtimeout int `json:"svrtimeout,omitempty"`
	/**
	* Enable client keep-alive for the service group.
	*/
	Cka string `json:"cka,omitempty"`
	/**
	* Enable TCP buffering for the service group.
	*/
	Tcpb string `json:"tcpb,omitempty"`
	/**
	* Enable compression for the specified service.
	*/
	Cmp string `json:"cmp,omitempty"`
	/**
	* Maximum bandwidth, in Kbps, allocated for all the services in the service group.
	*/
	Maxbandwidth int `json:"maxbandwidth,omitempty"`
	/**
	* Minimum sum of weights of the monitors that are bound to this service. Used to determine whether to mark a service as UP or DOWN.
	*/
	Monthreshold int `json:"monthreshold,omitempty"`
	/**
	* Initial state of the service group.
	*/
	State string `json:"state,omitempty"`
	/**
	* Flush all active transactions associated with all the services in the service group whose state transitions from UP to DOWN. Do not enable this option for applications that must complete their transactions.
	*/
	Downstateflush string `json:"downstateflush,omitempty"`
	/**
	* Name of the TCP profile that contains TCP configuration settings for the service group.
	*/
	Tcpprofilename string `json:"tcpprofilename,omitempty"`
	/**
	* Name of the HTTP profile that contains HTTP configuration settings for the service group.
	*/
	Httpprofilename string `json:"httpprofilename,omitempty"`
	/**
	* Any information about the service group.
	*/
	Comment string `json:"comment,omitempty"`
	/**
	* Enable logging of AppFlow information for the specified service group.
	*/
	Appflowlog string `json:"appflowlog,omitempty"`
	/**
	* Network profile for the service group.
	*/
	Netprofile string `json:"netprofile,omitempty"`
	/**
	* Auto scale option for a servicegroup
	*/
	Autoscale string `json:"autoscale,omitempty"`
	/**
	* member port
	*/
	Memberport int `json:"memberport,omitempty"`
	/**
	* Indicates graceful shutdown of the service. System will wait for all outstanding connections to this service to be closed before disabling the service.
	*/
	Autodisablegraceful string `json:"autodisablegraceful,omitempty"`
	/**
	* The time allowed (in seconds) for a graceful shutdown. During this period, new connections or requests will continue to be sent to this service for clients who already have a persistent session on the system. Connections or requests from fresh or new clients who do not yet have a persistence sessions on the system will not be sent to the service. Instead, they will be load balanced among other available services. After the delay time expires, no new requests or connections will be sent to the service.
	*/
	Autodisabledelay int `json:"autodisabledelay,omitempty"`
	/**
	* Close monitoring connections by sending the service a connection termination message with the specified bit set.
	*/
	Monconnectionclose string `json:"monconnectionclose,omitempty"`
	/**
	* Name of the server to which to bind the service group.
	*/
	Servername string `json:"servername,omitempty"`
	/**
	* Server port number.
	*/
	Port int `json:"port,omitempty"`
	/**
	* Weight to assign to the servers in the service group. Specifies the capacity of the servers relative to the other servers in the load balancing configuration. The higher the weight, the higher the percentage of requests sent to the service.
	*/
	Weight int `json:"weight,omitempty"`
	/**
	* The identifier for this IP:Port pair. Used when the persistency type is set to Custom Server ID.
	*/
	Customserverid string `json:"customserverid,omitempty"`
	/**
	* The  identifier for the service. This is used when the persistency type is set to Custom Server ID.
	*/
	Serverid int `json:"serverid,omitempty"`
	/**
	* The hash identifier for the service. This must be unique for each service. This parameter is used by hash based load balancing methods.
	*/
	Hashid int `json:"hashid,omitempty"`
	/**
	* Specify the nameserver to which the query for bound domain needs to be sent. If not specified, use the global nameserver
	*/
	Nameserver string `json:"nameserver,omitempty"`
	/**
	* Specify the TTL for DNS record for domain based service.The default value of ttl is 0 which indicates to use the TTL received in DNS response for monitors
	*/
	Dbsttl int `json:"dbsttl,omitempty"`
	/**
	* Name of the monitor bound to the service group. Used to assign a weight to the monitor.
	*/
	Monitornamesvc string `json:"monitor_name_svc,omitempty"`
	/**
	* weight of the monitor that is bound to servicegroup.
	*/
	Dupweight int `json:"dup_weight,omitempty"`
	/**
	* Time, in seconds, allocated for a shutdown of the services in the service group. During this period, new requests are sent to the service only for clients who already have persistent sessions on the appliance. Requests from new clients are load balanced among other available services. After the delay time expires, no requests are sent to the service, and the service is marked as unavailable (OUT OF SERVICE).
	*/
	Delay int `json:"delay,omitempty"`
	/**
	* Wait for all existing connections to the service to terminate before shutting down the service.
	*/
	Graceful string `json:"graceful,omitempty"`
	/**
	* Display the members of the listed service groups in addition to their settings. Can be specified when no service group name is provided in the command. In that case, the details displayed for each service group are identical to the details displayed when a service group name is provided, except that bound monitors are not displayed.
	*/
	Includemembers bool `json:"includemembers,omitempty"`
	/**
	* New name for the service group.
	*/
	Newname string `json:"newname,omitempty"`

	//------- Read only Parameter ---------;

	Numofconnections string `json:"numofconnections,omitempty"`
	Serviceconftype string `json:"serviceconftype,omitempty"`
	Value string `json:"value,omitempty"`
	Svrstate string `json:"svrstate,omitempty"`
	Ip string `json:"ip,omitempty"`
	Monstatcode string `json:"monstatcode,omitempty"`
	Monstatparam1 string `json:"monstatparam1,omitempty"`
	Monstatparam2 string `json:"monstatparam2,omitempty"`
	Monstatparam3 string `json:"monstatparam3,omitempty"`
	Statechangetimemsec string `json:"statechangetimemsec,omitempty"`
	Stateupdatereason string `json:"stateupdatereason,omitempty"`
	Clmonowner string `json:"clmonowner,omitempty"`
	Clmonview string `json:"clmonview,omitempty"`
	Groupcount string `json:"groupcount,omitempty"`
	Serviceipstr string `json:"serviceipstr,omitempty"`
	Servicegroupeffectivestate string `json:"servicegroupeffectivestate,omitempty"`
	Nodefaultbindings string `json:"nodefaultbindings,omitempty"`
	Svcitmactsvcs string `json:"svcitmactsvcs,omitempty"`
	Svcitmboundsvcs string `json:"svcitmboundsvcs,omitempty"`
	Monuserstatusmesg string `json:"monuserstatusmesg,omitempty"`

}


text:
<?php

namespace Facebook\Libphutil;

/**
 * String-like object which reduces the cost of managing large strings. This
 * is particularly useful for buffering large amounts of data that is being
 * passed to `fwrite()`.
 */
class PhutilRope extends \Facebook\Libphutil\Phobject {

  private $length = 0;
  private $buffers = array();

  // This is is arbitrary, it's just the maximum size I'm reliably able to
  // fwrite() to a pipe on OSX. In theory, we could tune this slightly based
  // on the pipe buffer size, but any value similar to this shouldn't affect
  // performance much.
  private $segmentSize = 16384;

  /**
   * Append a string to the rope.
   *
   * @param string String to append.
   * @return this
   */
  public function append($string) {
    if (!strlen($string)) {
      return $this;
    }

    $len = strlen($string);
    $this->length += $len;

    if ($len <= $this->segmentSize) {
      $this->buffers[] = $string;
    } else {
      for ($cursor = 0; $cursor < $len; $cursor += $this->segmentSize) {
        $this->buffers[] = substr($string, $cursor, $this->segmentSize);
      }
    }

    return $this;
  }

  /**
   * Get the length of the rope.
   *
   * @return int Length of the rope in bytes.
   */
  public function getByteLength() {
    return $this->length;
  }

  /**
   * Get an arbitrary, nonempty prefix of the rope.
   *
   * @return string Some rope prefix.
   */
  public function getAnyPrefix() {
    $result = reset($this->buffers);
    if ($result === false) {
      return null;
    }

    return $result;
  }

  /**
   * Return the entire rope as a normal string.
   *
   * @return string Normal string.
   */
  public function getAsString() {
    return implode('', $this->buffers);
  }

  /**
   * Remove a specified number of bytes from the head of the rope.
   *
   * @param int Bytes to remove.
   * @return this
   */
  public function removeBytesFromHead($length) {
    if ($length <= 0) {
      throw new \InvalidArgumentException(
        \Facebook\Libphutil\Functions\pht::pht('Length must be larger than 0!'));
    }

    $remaining_length = $length;
    foreach ($this->buffers as $key => $buf) {
      $len = strlen($buf);
      if ($len <= $length) {
        unset($this->buffers[$key]);
        $remaining_length -= $len;
        if (!$remaining_length) {
          break;
        }
      } else {
        $this->buffers[$key] = substr($buf, $length);
        break;
      }
    }

    if ($length <= $this->length) {
      $this->length -= $length;
    } else {
      $this->length = 0;
    }

    return $this;
  }

}


text:
package org.apache.twill.yarn;

import com.google.common.io.Files;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.twill.api.AbstractTwillRunnable;
import org.apache.twill.api.EventHandler;
import org.apache.twill.api.TwillApplication;
import org.apache.twill.api.TwillController;
import org.apache.twill.api.TwillRunner;
import org.apache.twill.api.TwillSpecification;
import org.apache.twill.api.logging.LogEntry;
import org.apache.twill.api.logging.LogHandler;
import org.apache.twill.api.logging.PrinterLogHandler;
import org.apache.twill.internal.yarn.YarnUtils;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

/**
 * Unit test for application master resilience.
 */
public class AppRecoveryTestRun extends BaseYarnTest {

  @ClassRule
  public static final TemporaryFolder TEMP_FOLDER = new TemporaryFolder();

  @Test
  public void testAMRestart() throws Exception {
    // Only run it with Hadoop-2.1 or above
    Assume.assumeTrue(YarnUtils.getHadoopVersion().compareTo(YarnUtils.HadoopVersions.HADOOP_21) >= 0);
    // Don't run this test in Mac, as there would be leftover java process (HADOOP-12317)
    // The test can be force to run by turning on the "force-mac-tests" maven profile
    // After the test finished, run the `jps` command and delete all `TwillLauncher` processes
    Assume.assumeTrue(Boolean.parseBoolean(System.getProperty("force.mac.tests")) ||
                      !System.getProperty("os.name").toLowerCase().contains("mac"));

    File watchFile = TEMP_FOLDER.newFile();
    watchFile.delete();

    // Start the testing app, and wait for 4 log lines that match the pattern emitted by the event handler (AM)
    // and from the runnable
    final Semaphore semaphore = new Semaphore(0);
    TwillRunner runner = getTwillRunner();
    TwillController controller = runner.prepare(new TestApp(new TestEventHandler(watchFile)))
      .addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
      // Use a log handler to match messages from AM and the Runnable to make sure the log collection get resumed
      // correctly after the AM restarted
      .addLogHandler(new LogHandler() {
        @Override
        public void onLog(LogEntry logEntry) {
          String message = logEntry.getMessage();
          if (message.equals("Container for " + TestRunnable.class.getSimpleName() + " launched")) {
            semaphore.release();
          } else if (message.equals("Running 0")) {
            semaphore.release();
          }
        }
      })
      .start();

    // Wait for the first attempt running
    Assert.assertTrue(semaphore.tryAcquire(2, 2, TimeUnit.MINUTES));
    // Touch the watchFile so that the event handler will kill the AM
    Files.touch(watchFile);
    // Wait for the second attempt running
    Assert.assertTrue(semaphore.tryAcquire(2, 2, TimeUnit.MINUTES));

    controller.terminate().get();
  }

  /**
   * A {@link EventHandler} for killing the first attempt of the application.
   */
  public static final class TestEventHandler extends EventHandler {

    private static final Logger LOG = LoggerFactory.getLogger(TestEventHandler.class);

    private File watchFile;

    TestEventHandler(File watchFile) {
      this.watchFile = watchFile;
    }

    @Override
    public void containerLaunched(String runnableName, int instanceId, String containerId) {
      LOG.info("Container for {} launched", runnableName);

      if (containerId.contains("_01_")) {
        final File watchFile = new File(context.getSpecification().getConfigs().get("watchFile"));
        Thread t = new Thread() {
          @Override
          public void run() {
            // Wait for the watch file to be available, then kill the process
            while (!watchFile.exists()) {
              Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
            }
            Runtime.getRuntime().halt(-1);
          }
        };
        t.setDaemon(true);
        t.start();
      }
    }

    @Override
    protected Map<String, String> getConfigs() {
      return Collections.singletonMap("watchFile", watchFile.getAbsolutePath());
    }
  }

  /**
   * Application for testing
   */
  public static final class TestApp implements TwillApplication {

    private final EventHandler eventHandler;

    public TestApp(EventHandler eventHandler) {
      this.eventHandler = eventHandler;
    }

    @Override
    public TwillSpecification configure() {
      return TwillSpecification.Builder.with()
        .setName("TestApp")
        .withRunnable()
        .add(new TestRunnable()).noLocalFiles()
        .anyOrder()
        .withEventHandler(eventHandler).build();
    }
  }

  /**
   * Runnable for testing
   */
  public static final class TestRunnable extends AbstractTwillRunnable {

    private static final Logger LOG = LoggerFactory.getLogger(TestRunnable.class);

    private final CountDownLatch stopLatch = new CountDownLatch(1);

    @Override
    public void run() {
      long count = 0;
      try {
        while (!stopLatch.await(2, TimeUnit.SECONDS)) {
          LOG.info("Running {}", count++);
        }
      } catch (InterruptedException e) {
        LOG.info("Interrupted", e);
      }
    }

    @Override
    public void stop() {
      stopLatch.countDown();
    }
  }
}


text:
package de.test.antennapod.storage;

import android.content.Context;

import junit.framework.Assert;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import de.danoeh.antennapod.core.feed.Chapter;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.SimpleChapter;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
import de.danoeh.antennapod.core.util.flattr.FlattrStatus;

/**
 * Utility methods for DB* tests.
 */
public class DBTestUtils {

    /**
     * Use this method when tests don't involve chapters.
     */
    public static List<Feed> saveFeedlist(Context context, int numFeeds, int numItems, boolean withMedia) {
        return saveFeedlist(context, numFeeds, numItems, withMedia, false, 0);
    }

    /**
     * Use this method when tests involve chapters.
     */
    public static List<Feed> saveFeedlist(Context context, int numFeeds, int numItems, boolean withMedia,
                                          boolean withChapters, int numChapters) {
        if (numFeeds <= 0) {
            throw new IllegalArgumentException("numFeeds<=0");
        }
        if (numItems < 0) {
            throw new IllegalArgumentException("numItems<0");
        }

        List<Feed> feeds = new ArrayList<Feed>();
        PodDBAdapter adapter = new PodDBAdapter(context);
        adapter.open();
        for (int i = 0; i < numFeeds; i++) {
            Feed f = new Feed(0, new Date(), "feed " + i, "link" + i, "descr", null, null,
                    null, null, "id" + i, null, null, "url" + i, false, new FlattrStatus(), false, null);
            f.setItems(new ArrayList<FeedItem>());
            for (int j = 0; j < numItems; j++) {
                FeedItem item = new FeedItem(0, "item " + j, "id" + j, "link" + j, new Date(),
                        true, f, withChapters);
                if (withMedia) {
                    FeedMedia media = new FeedMedia(item, "url" + j, 1, "audio/mp3");
                    item.setMedia(media);
                }
                if (withChapters) {
                    List<Chapter> chapters = new ArrayList<>();
                    item.setChapters(chapters);
                    for (int k = 0; k < numChapters; k++) {
                        chapters.add(new SimpleChapter(k, "item " + j + " chapter " + k, item, "http://example.com"));
                    }
                }
                f.getItems().add(item);
            }
            Collections.sort(f.getItems(), new FeedItemPubdateComparator());
            adapter.setCompleteFeed(f);
            Assert.assertTrue(f.getId() != 0);
            for (FeedItem item : f.getItems()) {
                Assert.assertTrue(item.getId() != 0);
            }
            feeds.add(f);
        }
        adapter.close();

        return feeds;
    }
}


text:
/*
 * Jacs -- Java augmented cipher streams.
 * See README.txt for more info.
 */

package net.openvpn.jacs.algs;

import net.openvpn.jacs.*;

/**
 * Crypto parameters for PBKDF2-SHA1 + AES-256 + HMAC-SHA-1 signature.
 */
public class PBKDF2_SHA1_AES256_HMAC_SHA1 extends PBKDF2_SHA1_AES256_HMAC_SHA256 {
	@Override
	public String name() {
		return "PBKDF2-SHA1-AES256-HMAC-SHA1";
	}

	@Override
	public CipherMacSpec create() {
		return new PBKDF2_SHA1_AES256_HMAC_SHA1();
	}

	protected String hmacAlg() {
		return "HmacSHA1";
	}
}


text:
<?php

namespace Prolong\UserBundle\Controller;

use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Util\Codes;
use FOS\RestBundle\View\View;
use JMS\Serializer\SerializationContext;
use Prolong\UserBundle\Entity\User;
use Prolong\UserBundle\Form\FormLogin;
use Prolong\UserBundle\Service\UserService;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;

use FOS\RestBundle\Controller\Annotations as Rest;
use Symfony\Component\HttpFoundation\Session\Session;

/**
 * Class UserController
 * @package Prolong\UserBundle\Controller
 */
class UserController extends FOSRestController
{

    /**
     * @param Request $request the request object
     * @Rest\View()
     *
     * @return View
     */
    public function loginAction(Request $request)
    {
        /** @var Form $form */
        $form = $this->get('form.user_login');
        $form->handleRequest($request);

        $entity = null;

        if ($form->isValid()) {

            $userService = $this->getUserService();

            /** @var User $entity */
            $entity = $form->getData();

            $entity = $userService->login($entity);

            if (empty($entity)) {
                return View::create(['error' => 'Login failed'],
                    Codes::HTTP_BAD_REQUEST);
            }
        } else {
            return View::create(['error' => 'Invalid argument'],
                Codes::HTTP_BAD_REQUEST);
        }

        $view = View::create();
        $view->setStatusCode(Codes::HTTP_CREATED);
        $view->setData([
            "code" => Codes::HTTP_CREATED,
            "response" => $entity,
        ]);
        $view->setSerializationContext(SerializationContext::create()
            ->setGroups(['register']));

        return $view;
    }

    /**
     * @param Request $request the request object
     * @Rest\View()
     *
     * @return View
     */
    public function registerAction(Request $request)
    {
        /** @var Form $form */
        $form = $this->get('form.user_register');
        $form->handleRequest($request);

        $entity = null;

        if ($form->isValid()) {

            $userService = $this->getUserService();

            /** @var User $entity */
            $entity = $form->getData();

            $entity = $userService->register($entity);

            if (empty($entity)) {
                return View::create(['error' => 'Mail already exists'],
                    Codes::HTTP_BAD_REQUEST);
            }
        } else {
            return View::create(['error' => 'Invalid argument'],
                Codes::HTTP_BAD_REQUEST);
        }

        $view = View::create();
        $view->setStatusCode(Codes::HTTP_CREATED);
        $view->setData([
            'code' => Codes::HTTP_CREATED,
            'response' => $entity,
        ]);
        $view->setSerializationContext(SerializationContext::create()
            ->setGroups(['register']));

        return $view;
    }

    /**
     * @param Request $request the request object
     * @Rest\View()
     *
     * @return View
     */
    public function meAction(Request $request)
    {

        $session = $request->getSession();

        if (!$session) {
            $session = new Session();
        }

        if (!$session->isStarted()) {
            $session->start();
        }

        $userService = $this->getUserService();

        $user = $userService->getUser();

        if ($user) {
            $view = View::create();
            $view->setStatusCode(Codes::HTTP_CREATED);
            $view->setData([
                'code' => Codes::HTTP_CREATED,
                'response' => $user,
            ]);
            $view->setSerializationContext(SerializationContext::create()
                ->setGroups(['me']));

        } else {
            $view = View::create(['error' => 'Anonymous'],
                Codes::HTTP_BAD_REQUEST);
        }

        return $view;
    }

    /**
     * @return UserService
     */
    protected function getUserService()
    {
        return $this->container->get('service.user');
    }
}


text:
#ifndef LIBPORT_MARKUP_OSTREAM_HH
# define LIBPORT_MARKUP_OSTREAM_HH

# include <boost/function.hpp>

# include <libport/export.hh>
# include <libport/io-stream.hh>

namespace libport
{
  class MarkupStreamBuffer;

  class LIBPORT_API MarkupOStream: public libport::IOStream
  {
  public:
    typedef libport::IOStream super_type;
    MarkupOStream(std::ostream& output);

    void col();
    void etable();
    void row();
    void table();

  private:
    MarkupStreamBuffer* buffer_;
  };

  LIBPORT_API std::ostream& col(std::ostream& where);
  LIBPORT_API std::ostream& etable(std::ostream& where);
  LIBPORT_API std::ostream& row(std::ostream& where);
  LIBPORT_API std::ostream& table(std::ostream& where);
}

#endif


text:
package de.tudarmstadt.ukp.clarin.webanno.api.format;

import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.cas.CAS;
import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.metadata.TypeSystemDescription;

import de.tudarmstadt.ukp.clarin.webanno.model.Project;
import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument;

public interface FormatSupport
{
    /**
     * Returns the format identifier which is stored in in {@link SourceDocument#setFormat(String)}.
     *
     * @return the format identifier.
     */
    String getId();

    /**
     * @return a format name displayed in the UI.
     */
    String getName();

    /**
     * @return whether the format can be reader (i.e. {@link #getReaderDescription} is implemented).
     */
    default boolean isReadable()
    {
        return false;
    }

    /**
     * @return whether the format can be written (i.e. {@link #getWriterDescription} is
     *         implemented).
     */
    default boolean isWritable()
    {
        return false;
    }

    /**
     * @return a UIMA reader description.
     */
    default CollectionReaderDescription getReaderDescription(TypeSystemDescription aTSD)
        throws ResourceInitializationException
    {
        throw new UnsupportedOperationException("The format [" + getName() + "] cannot be read");
    }

    /**
     * @return a UIMA reader description.
     */
    default AnalysisEngineDescription getWriterDescription(Project aProject,
            TypeSystemDescription aTSD, CAS aCAS)
        throws ResourceInitializationException
    {
        throw new UnsupportedOperationException("The format [" + getName() + "] cannot be written");
    }
}


text:
package dgi.soap.consultas;

import javax.xml.bind.annotation.XmlRegistry;

/**
 * This object contains factory methods for each
 * Java content interface and Java element interface
 * generated in the dgi.soap.consultas package.
 * <p>An ObjectFactory allows you to programatically
 * construct new instances of the Java representation
 * for XML content. The Java representation of XML
 * content can consist of schema derived interfaces
 * and classes representing the binding of schema
 * type definitions, element declarations and model
 * groups.  Factory methods for each of these are
 * provided in this class.
 *
 */
@XmlRegistry
public class ObjectFactory {

    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: dgi.soap.consultas
     *
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARESTADOCFE }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARESTADOCFE createWSEFacturaConsultasEFACCONSULTARESTADOCFE() {
        return new WSEFacturaConsultasEFACCONSULTARESTADOCFE();
    }

    /**
     * Create an instance of {@link CFEId }
     *
     */
    public CFEId createCFEId() {
        return new CFEId();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARESTADOCFEResponse }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARESTADOCFEResponse createWSEFacturaConsultasEFACCONSULTARESTADOCFEResponse() {
        return new WSEFacturaConsultasEFACCONSULTARESTADOCFEResponse();
    }

    /**
     * Create an instance of {@link ACKConsultaEstadoCFE }
     *
     */
    public ACKConsultaEstadoCFE createACKConsultaEstadoCFE() {
        return new ACKConsultaEstadoCFE();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARENVIOSCFE }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARENVIOSCFE createWSEFacturaConsultasEFACCONSULTARENVIOSCFE() {
        return new WSEFacturaConsultasEFACCONSULTARENVIOSCFE();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARENVIOSCFEResponse }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARENVIOSCFEResponse createWSEFacturaConsultasEFACCONSULTARENVIOSCFEResponse() {
        return new WSEFacturaConsultasEFACCONSULTARENVIOSCFEResponse();
    }

    /**
     * Create an instance of {@link ACKConsultaEnviosCFE }
     *
     */
    public ACKConsultaEnviosCFE createACKConsultaEnviosCFE() {
        return new ACKConsultaEnviosCFE();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARENVIOSSOBRE }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARENVIOSSOBRE createWSEFacturaConsultasEFACCONSULTARENVIOSSOBRE() {
        return new WSEFacturaConsultasEFACCONSULTARENVIOSSOBRE();
    }

    /**
     * Create an instance of {@link ConsultaEnviosSobre }
     *
     */
    public ConsultaEnviosSobre createConsultaEnviosSobre() {
        return new ConsultaEnviosSobre();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARENVIOSSOBREResponse }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARENVIOSSOBREResponse createWSEFacturaConsultasEFACCONSULTARENVIOSSOBREResponse() {
        return new WSEFacturaConsultasEFACCONSULTARENVIOSSOBREResponse();
    }

    /**
     * Create an instance of {@link ACKConsultaEnviosSobre }
     *
     */
    public ACKConsultaEnviosSobre createACKConsultaEnviosSobre() {
        return new ACKConsultaEnviosSobre();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARCFERECIBIDOS }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARCFERECIBIDOS createWSEFacturaConsultasEFACCONSULTARCFERECIBIDOS() {
        return new WSEFacturaConsultasEFACCONSULTARCFERECIBIDOS();
    }

    /**
     * Create an instance of {@link ConsultaCFERecibidos }
     *
     */
    public ConsultaCFERecibidos createConsultaCFERecibidos() {
        return new ConsultaCFERecibidos();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARCFERECIBIDOSResponse }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARCFERECIBIDOSResponse createWSEFacturaConsultasEFACCONSULTARCFERECIBIDOSResponse() {
        return new WSEFacturaConsultasEFACCONSULTARCFERECIBIDOSResponse();
    }

    /**
     * Create an instance of {@link ACKConsultaCFERecibidos }
     *
     */
    public ACKConsultaCFERecibidos createACKConsultaCFERecibidos() {
        return new ACKConsultaCFERecibidos();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARENVIOSREPORTE }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARENVIOSREPORTE createWSEFacturaConsultasEFACCONSULTARENVIOSREPORTE() {
        return new WSEFacturaConsultasEFACCONSULTARENVIOSREPORTE();
    }

    /**
     * Create an instance of {@link ConsultaEnviosReporte }
     *
     */
    public ConsultaEnviosReporte createConsultaEnviosReporte() {
        return new ConsultaEnviosReporte();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARENVIOSREPORTEResponse }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARENVIOSREPORTEResponse createWSEFacturaConsultasEFACCONSULTARENVIOSREPORTEResponse() {
        return new WSEFacturaConsultasEFACCONSULTARENVIOSREPORTEResponse();
    }

    /**
     * Create an instance of {@link ACKConsultaEnviosReporte }
     *
     */
    public ACKConsultaEnviosReporte createACKConsultaEnviosReporte() {
        return new ACKConsultaEnviosReporte();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTE }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTE createWSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTE() {
        return new WSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTE();
    }

    /**
     * Create an instance of {@link ConsultaRespuestaReporte }
     *
     */
    public ConsultaRespuestaReporte createConsultaRespuestaReporte() {
        return new ConsultaRespuestaReporte();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTEResponse }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTEResponse createWSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTEResponse() {
        return new WSEFacturaConsultasEFACCONSULTARRESPUESTAREPORTEResponse();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARRUCEMISORES }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARRUCEMISORES createWSEFacturaConsultasEFACCONSULTARRUCEMISORES() {
        return new WSEFacturaConsultasEFACCONSULTARRUCEMISORES();
    }

    /**
     * Create an instance of {@link ConsultaRUCEmisores }
     *
     */
    public ConsultaRUCEmisores createConsultaRUCEmisores() {
        return new ConsultaRUCEmisores();
    }

    /**
     * Create an instance of {@link WSEFacturaConsultasEFACCONSULTARRUCEMISORESResponse }
     *
     */
    public WSEFacturaConsultasEFACCONSULTARRUCEMISORESResponse createWSEFacturaConsultasEFACCONSULTARRUCEMISORESResponse() {
        return new WSEFacturaConsultasEFACCONSULTARRUCEMISORESResponse();
    }

    /**
     * Create an instance of {@link RucEmisoresMail }
     *
     */
    public RucEmisoresMail createRucEmisoresMail() {
        return new RucEmisoresMail();
    }

    /**
     * Create an instance of {@link EFacParamConsulta }
     *
     */
    public EFacParamConsulta createEFacParamConsulta() {
        return new EFacParamConsulta();
    }

    /**
     * Create an instance of {@link ArrayOfDatosSobre }
     *
     */
    public ArrayOfDatosSobre createArrayOfDatosSobre() {
        return new ArrayOfDatosSobre();
    }

    /**
     * Create an instance of {@link DatosSobre }
     *
     */
    public DatosSobre createDatosSobre() {
        return new DatosSobre();
    }

    /**
     * Create an instance of {@link ArrayOfDatosCFE }
     *
     */
    public ArrayOfDatosCFE createArrayOfDatosCFE() {
        return new ArrayOfDatosCFE();
    }

    /**
     * Create an instance of {@link DatosCFE }
     *
     */
    public DatosCFE createDatosCFE() {
        return new DatosCFE();
    }

    /**
     * Create an instance of {@link ArrayOfDatosReporte }
     *
     */
    public ArrayOfDatosReporte createArrayOfDatosReporte() {
        return new ArrayOfDatosReporte();
    }

    /**
     * Create an instance of {@link DatosReporte }
     *
     */
    public DatosReporte createDatosReporte() {
        return new DatosReporte();
    }

    /**
     * Create an instance of {@link RucEmisoresMailRucEmisoresMailItem }
     *
     */
    public RucEmisoresMailRucEmisoresMailItem createRucEmisoresMailRucEmisoresMailItem() {
        return new RucEmisoresMailRucEmisoresMailItem();
    }

}


text:
set -o errexit

cd definitions
npm install
npm test
cd ../cli
npm install
node dist/cli.js validate-defs ../definitions
node dist/cli.js run-tests "$@"


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Bot. Jb. 22(2): 351 (1896)

#### Original name
Puccinia unciniarum Dietel & Neger, 1896

### Remarks
null


text:
@interface UIBezierPath (YNLength)

- (CGFloat)yn_length;

- (CGPoint)yn_pointAtPercentOfLength:(CGFloat)percent;

@end


text:
import os
import subprocess
from attachments.backends import ThumbnailerBase

class Thumbnailer(ThumbnailerBase):
    mime_types = (
        'application/pdf',
        'application/x-pdf',
    )

    def thumbnail(self, src_path, dst_path, width, heigth, mime_type):
        args = [
            'gm',
            'convert',
            '-quality', '85',
            '-colorspace', 'rgb',
            '-colors', '256',
            '-antialias',
            '-resize', '{w}x{h}'.format(w=width, h=heigth),
            'PDF:{src}[0]'.format(src=src_path),
            'PNG:{dst}'.format(dst=dst_path),
        ]

        proc = subprocess.Popen(args,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                env={'LANG': 'C'},
                               )
        out = proc.communicate()

        if out[0]:
            return (False, 'Convert error:'+out[1])

        if not os.path.isfile(dst_path):
            return (False, 'failed')

        return (True, 'image/png')


text:
package uk.ac.shef.dcs.kbproxy;

import java.io.IOException;
import java.util.Map;

public interface ProxiesFactory {

  Proxy create(ProxyDefinition definition, Map<String, String> prefixesToUris);

  void dispose(final String name) throws IOException;

}


text:
/*body*/
body{
	font-family:georgia;
	font-style:italic;
	color:#727272;
	font-size:7mm;}

.clearfix{clear:both;}

table{
	border-collapse:collapse;
	width:100%;
	padding:0px;
	margin:0px;
	}
td{
	margin:0px;
	border: 1px dotted #eaeaea;
	border-bottom: 1px solid #c0c0c0;
	padding-top:5px;
	padding-bottom:5px;
	}

#fields-items td, #cover-items td,#fields-report td {text-align:center;}

tr{}

form{
	margin-top:10px;
	margin-bottom:10px;
	}

h2{
	margin-top:0px;
	background: url(images/red-cross.png) no-repeat bottom right;
}
	/*
masthead
*/

#masthead{
	background:#c0c0c0 url(images/Info.png) 95% 50% no-repeat;
	padding:10px;
	border-bottom:2px solid #80ff00;
	margin-bottom:10px;
	color:#3b3b3b;

}

/*menu screen*/
.menu-item{
	line-height: 1.9em;
	border-bottom:1px solid #e4e4e4;
	font-size:1.2em;
	}
#fields-menu-item{
	background:url(images/fields.png) no-repeat right bottom;
}
#cover-menu-item{
	background:url(images/cover.png) no-repeat right bottom;
}
#graphs-menu-item{
	background:url(images/graphs.png) no-repeat right bottom;
}
#reports-menu-item{
	background:url(images/papers.png) no-repeat right bottom;
}
#settings-menu-item{
	background:url(images/spanner.png) no-repeat right bottom;
}
#load-save-menu-item{
	background:url(images/disk.png) no-repeat right bottom;
}
/*
fields screen
*/
#enter-new-field-button{
	background:#eaeaea url(images/green-cross.png) no-repeat 5px ;
	padding:8px;
	padding-left:50px;
	border-top:1px solid #727272;
	border-bottom:1px solid #727272;
	text-align:center;
}
.header{
	text-align:center;
	margin-top:10px;
	padding:5px;
	border-bottom:1px solid #727272;
	}

.edit-button{
	background:url(images/pencil.png) no-repeat center;
	width:40px;
	}

/*
new field screen
*/
.save{
	float:left;
	}
.cancel{
	float:right;
}
.save,.cancel{
	border:1px solid #727272;
	background:#eaeaea;
	padding:5px;
}

#edit-field-delete-button{
	margin:auto;
	border:1px solid #727272;
	background:#eaeaea url(images/red-cross.png) no-repeat bottom right;
	padding:5px;
	width:110px;

	}

/*
reports screen
*/
#fields-report table{
	font-size:0.7em;
	width:100%;
}

/*
graphs
*/
#graph-legend{font-size:6mm}
.graphBar {
	border-bottom: none;
	font-size:6mm;
	list-style:none;
	margin: 0;
	padding: 0;
	position:relative;
	text-align: center;
	width: 39px;
	float:left;
	bottom: 0px;
	background: #666 ;
	border: 1px solid #555;
	}

#chart{
	border-top: 3px solid #333;
	font: 9px Helvetica, Geneva, sans-serif;
	height: 200px;
	margin: 0;
	padding: 0;
	position: relative;
	margin-top:200px;
	}

#graphs-screen{background-color:#fefefe;}

div.graphBar{color:red;}

#reset-menu-item{color:red;font-weight:bold;border:}

/*
info/about screen
*/
#info-screen p, #info-screen li{font-size:6mm;}
#info-screen li{margin-top:10px;margin-bottom:10px;}

/*
load save screen

*/
#load-save-screen p{font-size:6mm;}


text:
package ca.sharvey.reddit.irc;

public class IRC {

}


text:
var _curry1 = require('./internal/_curry1');
var _has = require('./internal/_has');

/**
 * Returns a list containing the names of all the enumerable own properties of
 * the supplied object.
 * Note that the order of the output array is not guaranteed to be consistent
 * across different JS platforms.
 *
 * @func
 * @memberOf R
 * @since v0.1.0
 * @category Object
 * @sig {k: v} -> [k]
 * @param {Object} obj The object to extract properties from
 * @return {Array} An array of the object's own properties.
 * @example
 *
 *      R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
 */
module.exports = (function() {
  // cover IE < 9 keys issues
  var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString');
  var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString',
                            'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];

  var contains = function contains(list, item) {
    var idx = 0;
    while (idx < list.length) {
      if (list[idx] === item) {
        return true;
      }
      idx += 1;
    }
    return false;
  };

  return typeof Object.keys === 'function' ?
    _curry1(function keys(obj) {
      return Object(obj) !== obj ? [] : Object.keys(obj);
    }) :
    _curry1(function keys(obj) {
      if (Object(obj) !== obj) {
        return [];
      }
      var prop, ks = [], nIdx;
      for (prop in obj) {
        if (_has(prop, obj)) {
          ks[ks.length] = prop;
        }
      }
      if (hasEnumBug) {
        nIdx = nonEnumerableProps.length - 1;
        while (nIdx >= 0) {
          prop = nonEnumerableProps[nIdx];
          if (_has(prop, obj) && !contains(ks, prop)) {
            ks[ks.length] = prop;
          }
          nIdx -= 1;
        }
      }
      return ks;
    });
}());


text:
@protocol  CycleScrollViewDelegate

- (void) onCycleScrollViewClick:(NSInteger)index;

@end

@interface CycleScrollViewCell : UITableViewCell

@property (nonatomic, retain) UIScrollView * scrollView;
@property (nonatomic, retain) UIPageControl * pageControl;
@property (nonatomic, retain) NSArray * data;

@property (nonatomic, weak) id <CycleScrollViewDelegate>delegate;

@end


text:
package net.tascalate.concurrent.delays;

import java.time.Duration;

import net.tascalate.concurrent.DelayPolicy;
import net.tascalate.concurrent.RetryContext;

public class OnSuccessNoDelayPolicy<T> extends DelayPolicyWrapper<T> {

    public OnSuccessNoDelayPolicy(DelayPolicy<? super T> target) {
        super(target);
    }

    @Override
    public Duration delay(RetryContext<? extends T> context) {
        return context.getLastError() == null ? Duration.ZERO : target.delay(context);
    }
}


text:
import os
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
# To set up environmental variables, see http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = Client(account_sid, auth_token)
activities = client.taskrouter.workspaces(workspace_sid).activities.list()

for activity in activities:
    print(activity.friendly_name)


text:
REPORTER = spec

# Global
test: test-unit test-functional
test-functional: test-headless
test-unit: test-unit-db
# Functional Tests
test-headless:
		./node_modules/.bin/mocha ./test/functional/headless/* \
		--reporter $(REPORTER)
# Unit Tests
test-unit-db:
		./node_modules/.bin/mocha ./test/unit/db/* \
		--reporter $(REPORTER) \