Construct a Pat object from the specified string
        and optimal position count.
762499
def from_chars(cls, chars='', optimal=3):
        """"""
        if not chars:
            chars = ''.join(ALNUM)
        sets = most_even_chunk(chars, optimal)
        return cls(sets)
74237
function fromString (string) {
  assert.equal(typeof string, 'string')

  return from(function (size, next) {
    if (string.length <= 0) return this.push(null)

    const chunk = string.slice(0, size)
    string = string.slice(size)

    next(null, chunk)
  })
}
725291
void tokenize(String pat) throws javax.xml.transform.TransformerException
  {
    tokenize(pat, null);
  }
397410
def schunk(string, size):
    """"""
    return [string[i:i+size] for i in range(0, len(string), size)]
1363137
def counter_from_str(self, string):
        """"""
        string_list = [chars for chars in string if chars not in self.punctuation]
        string_joined = ''.join(string_list)
        tokens = self.punkt.word_tokenize(string_joined)
        return Counter(tokens)
1240575
def from_string(cls, string):
        
        items = shlex.split(string, **cls.split_args)
        return cls(items)
432121
def from_str(self, instr):
        ''''''
        if not instr:
            return FlexiDate()

        out = self.our_re.match(instr)
        if out is None:  # no match TODO: raise Exception?
            return None
        else:
            return FlexiDate(
                out.group('year'),
                out.group('month'),
                out.group('day'),
                out.group('hour'),
                out.group('minute'),
                out.group('second'),
                out.group('microsecond'),
                qualifier=out.group('qualifier')
            )
868727
def from_string(cls, string):
    """"""
    # Note: There is some ambiguity as to whether the string passed is intended
    # to become a unit looked up by name or suffix, or a Dimension descriptor.
    if string in units.UNITS_BY_ALL:
      return cls(description=string, unit=units.Unit(string))
    else:
      return cls(description=string)
700757
def score_string( self, string ):
        
        rval = zeros( len( string ), float32 )
        rval[:] = nan
        _pwm.score_string( self.values, self.char_to_index, string, rval )
        return rval
14598
def initialize_from_string(content: str) -> 'CapitanSymbol':
        

        if content is None or content is "":
            return None

        parts = content.split(":")
        min_x = 100000
        max_x = 0
        min_y = 100000
        max_y = 0

        symbol_name = parts[0]

        sequence = parts[1]
        image_numbers = parts[2].split(',')
        image_data = numpy.asarray(image_numbers, numpy.uint8).reshape((30, 30))

        stroke = []

        for point_string in sequence.split(";"):
            if point_string is "":
                continue  # Skip the last element, that is due to a trailing ; in each line

            point_x, point_y = point_string.split(",")
            x = float(point_x)
            y = float(point_y)
            stroke.append(SimplePoint2D(x, y))

            max_x = max(max_x, x)
            min_x = min(min_x, x)
            max_y = max(max_y, y)
            min_y = min(min_y, y)

        dimensions = Rectangle(Point2D(min_x, min_y), int(max_x - min_x + 1), int(max_y - min_y + 1))
        return CapitanSymbol(content, stroke, image_data, symbol_name, dimensions)
655632
function createLiterallyObjects(query, openPos, stringPositions) {
    const firstRaw = query.substr(0, openPos)
    const result = [firstRaw.trim()]
    let pointer = 0

    stringPositions.forEach((stringPosition) => {
        if (!stringPosition.end) {
            throw new SyntaxException('Invalid string ending found.')
        }

        if (stringPosition.end < firstRaw.length) {
            // At least one string exists in first part, create a new object.

            // Remove the last part, since this wasn't parsed.
            result.pop()

            // Add part between pointer and string occurrence.
            result.push(firstRaw.substr(pointer, stringPosition.start - pointer).trim())

            // Add the string as object.
            result.push(new Literally(firstRaw.substr(
                stringPosition.start + 1,
                stringPosition.end - stringPosition.start
            )))

            result.push(firstRaw.substr(stringPosition.end + 2).trim())

            pointer = stringPosition.end + 2
        }
    })

    return result
}
1335326
def _construct_regex(cls, fmt):
        """"""
        return re.compile(fmt.format(**vars(cls)), flags=re.U)
1057674
def from_bytes(self, string):
        """"""
        msg = srsly.msgpack_loads(gzip.decompress(string))
        self.attrs = msg["attrs"]
        self.strings = set(msg["strings"])
        lengths = numpy.fromstring(msg["lengths"], dtype="int32")
        flat_spaces = numpy.fromstring(msg["spaces"], dtype=bool)
        flat_tokens = numpy.fromstring(msg["tokens"], dtype="uint64")
        shape = (flat_tokens.size // len(self.attrs), len(self.attrs))
        flat_tokens = flat_tokens.reshape(shape)
        flat_spaces = flat_spaces.reshape((flat_spaces.size, 1))
        self.tokens = NumpyOps().unflatten(flat_tokens, lengths)
        self.spaces = NumpyOps().unflatten(flat_spaces, lengths)
        for tokens in self.tokens:
            assert len(tokens.shape) == 2, tokens.shape
        return self
218079
def from_str(string, max_number=9, separator="."):
        
        tokens = string.split(separator)
        tokens = list(reversed(tokens))  # reverse order of importance
        most_important = tokens[-1]  # cannot be parsed like the others
        levels = [
            Level(max_number, int(token)) for token in tokens[:-1]
        ]
        levels.append(
            Level(float("inf"), int(most_important))
        )

        return Subsystem(levels, separator)
770017
def _extract(expr, pat, flags=0, group=0):
    

    return _string_op(expr, Extract, _pat=pat, _flags=flags, _group=group)
133036
def _startswith(expr, pat):
    

    return _string_op(expr, Startswith, output_type=types.boolean, _pat=pat)
1261991
def from_string(cls, s):
        
        # Extract num and unit string.
        s = s.strip()
        for i, char in enumerate(s):
            if char.isalpha() or char.isspace():
                break
        else:
            raise Exception("Unit is missing in string %s" % s)
        num, unit = float(s[:i]), s[i:]

        # Find unit type (set it to None if it cannot be detected)
        for unit_type, d in BASE_UNITS.items():
            if unit in d:
                break
        else:
            unit_type = None

        return cls(num, unit, unit_type=unit_type)