class_docstr: FixedLengthUnit Class.
  
  Process unit to get the fixed length text.
  
  Examples:
      >>> from matchzoo.preprocessors.units import FixedLength
      >>> fixedlen = FixedLength(3)
      >>> fixedlen.transform(list(range(1, 6))) == [3, 4, 5]
      True
      >>> fixedlen.transform(list(range(1, 3))) == [0, 1, 2]
      True
docstr: Class initialization.
  
  :param text_length: fixed length of the text.
  :param pad_value: if text length is smaller than :attr:`text_length`,
      filling text with :attr:`pad_value`.
  :param pad_mode: String, `pre` or `post`:
      pad either before or after each sequence.
  :param truncate_mode: String, `pre` or `post`:
      remove values from sequences larger than :attr:`text_length`,
      either at the beginning or at the end of the sequences.
docstr_tok: ["Class","initialization",".",":","param","text_length",":","fixed","length","of","the","text",".",":","param","pad_value",":","if","text","length","is","smaller","than",":","attr",":","`","text_length","`",",","filling","text","with",":","attr",":","`","pad_value","`",".",":","param","pad_mode",":","String",",","`","pre","`","or","`","post","`",":","pad","either","before","or","after","each","sequence",".",":","param","truncate_mode",":","String",",","`","pre","`","or","`","post","`",":","remove","values","from","sequences","larger","than",":","attr",":","`","text_length","`",",","either","at","the","beginning","or","at","the","end","of","the","sequences","."]
code: def __init__(
      self,
      text_length: int,
      pad_value: typing.Union[int, str] = 0,
      pad_mode: str = "pre",
      truncate_mode: str = "pre",
  ):
      """
      Class initialization.
  
      :param text_length: fixed length of the text.
      :param pad_value: if text length is smaller than :attr:`text_length`,
          filling text with :attr:`pad_value`.
      :param pad_mode: String, `pre` or `post`:
          pad either before or after each sequence.
      :param truncate_mode: String, `pre` or `post`:
          remove values from sequences larger than :attr:`text_length`,
          either at the beginning or at the end of the sequences.
      """
      self._text_length = text_length
      self._pad_value = pad_value
      self._pad_mode = pad_mode
      self._truncate_mode = truncate_mode
  
imports: import typing
  import numpy
  from .unit import Unit
label_desc: Use image node_id 1 to create a new FixedLength object from inherited base classes: Unit with example: obj = FixedLength(text_length, pad_value, pad_mode, truncate_mode)