Parse and convert a string representation
    of an example into a LabeledTree datastructure.

    Arguments:
    ----------
        line : str, string version of the tree.

    Returns:
    --------
        LabeledTree : parsed tree.
326543
def create_tree_from_string(line):
    
    depth         = 0
    current_word  = ""
    root          = None
    current_node  = root

    for char in line:
        if char == '(':
            if current_node is not None and len(current_word) > 0:
                attribute_text_label(current_node, current_word)
                current_word = ""
            depth += 1
            if depth > 1:
                # replace current head node by this node:
                child = LabeledTree(depth=depth)
                current_node.add_child(child)
                current_node = child
                root.add_general_child(child)
            else:
                root = LabeledTree(depth=depth)
                root.add_general_child(root)
                current_node = root

        elif char == ')':
            # assign current word:
            if len(current_word) > 0:
                attribute_text_label(current_node, current_word)
                current_word = ""

            # go up a level:
            depth -= 1
            if current_node.parent != None:
                current_node.parent.udepth = max(current_node.udepth+1, current_node.parent.udepth)
            current_node = current_node.parent
        else:
            # add to current read word
            current_word += char
    if depth != 0:
        raise ParseError("Not an equal amount of closing and opening parentheses")

    return root
735190
def tree(self):
        
        tree = self.get('tree')
        if isinstance(tree, stringtypes):
            tree = SExpr.parse(tree).data
        elif tree is None:
            drv = self.get('derivation')
            if isinstance(drv, dict) and 'label' in drv:
                def _extract_tree(d):
                    t = [d.get('label', '')]
                    if 'tokens' in d:
                        t.append([d.get('form', '')])
                    else:
                        for dtr in d.get('daughters', []):
                            t.append(_extract_tree(dtr))
                    return t
                tree = _extract_tree(drv)
        return tree
865669
def parse(cls, value):
    
    if is_list_annotation(cls):
        if not isinstance(value, list):
            raise TypeError('Could not parse {} because value is not a list'.format(cls))
        return [parse(cls.__args__[0], o) for o in value]
    else:
        return GenericParser(cls, ModelProviderImpl()).parse(value)
100923
def parse(self, lint_target):  # type: (AbstractLintTarget) -> Dict[str, Any]
        
        decoder = Decoder(default_decoding_strategy)
        decoded = decoder.decode(lint_target.read())
        decoded_and_lf_normalized = decoded.replace('\r\n', '\n')

        return self.parse_string(decoded_and_lf_normalized)
173045
def parse(self, lines):
    

    if isinstance(lines, str):
      lines = lines.split('\n')
    sub = _re.sub
    for line in lines:
      if line.endswith('\n'):
        line = line[:-1]
      line = line.lstrip()
      if not line.startswith('#'):
        invert = False
        if line.startswith('!'):
          line = line[1:]
          invert = True
        while line.endswith(' ') and line[-2:] != '\ ':
          line = line[:-1]
        line = sub(r'\\([!# ])', r'\1', line)
        if '/' in line and not line.startswith('/'):
          # Patterns with a slash can only be matched absolute.
          line = '/' + line
        self.patterns.append(Pattern(line, invert))
692835
def parsePoint(line):
    
    values = [float(s) for s in line.split(' ')]
    if values[0] == -1:   # Convert -1 labels to 0 for MLlib
        values[0] = 0
    return LabeledPoint(values[0], values[1:])
141131
def parse (cls, line, lineno, log, cmddict=None):
    
    start  = line.find('{')
    stop   = line.find('}')
    pos    = SeqPos(line, lineno, start + 1, stop)
    result = cls(None, pos)

    if start >= 0 and stop >= start:
      attrs = { }
      pairs = line[start + 1:stop].split(',')

      for item in pairs:
        ncolons = item.count(':')
        if ncolons == 0:
          log.error('Missing colon in command attribute "%s".' % item, pos)
        elif ncolons > 1:
          log.error('Too many colons in command attribute "%s".' % item, pos)
        else:
          name, value = (s.strip() for s in item.split(':'))
          attrs[name] = value

      result = cls(attrs, pos)

    elif start != -1 or stop != -1:
      log.error('Incorrect command attribute curly brace placement.', pos)

    return result
1369724
def parse(self, lines):
        ''''''
        if self.type == 'msdos':
            return self.parse_msdos(lines)
        elif self.type == 'unix':
            return self.parse_unix(lines)
        elif self.type == 'nlst':
            return self.parse_nlst(lines)
        else:
            raise UnknownListingError('Unsupported listing type.')
206469
def find_stringy_lines(tree: ast.AST, first_line_no: int) -> Set[int]:
    
    str_footprints = set()
    for node in ast.walk(tree):
        if isinstance(node, ast.Str):
            str_footprints.update(build_footprint(node, first_line_no))
    return str_footprints
122148
def parse_line(line: str, char_index=0) -> Tuple[ListingType, str]:
    """"""

    entry_name = str.rpartition(line, ' ')[-1]
    entry_type = LISTING_FLAG_MAP.get(line[char_index], ListingType.other)
    return entry_type, entry_name
211933
def decode(cls, line):
        
        if line.encoded:
            line.value = stringToTextValues(line.value,
                listSeparator=cls.listSeparator)
            line.encoded=False
139966
def handle_label_relation(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        
        subject_node_dsl = self.ensure_node(tokens[SUBJECT])
        description = tokens[OBJECT]

        if self.graph.has_node_description(subject_node_dsl):
            raise RelabelWarning(
                line_number=self.get_line_number(),
                line=line,
                position=position,
                node=self.graph.node,
                old_label=self.graph.get_node_description(subject_node_dsl),
                new_label=description
            )

        self.graph.set_node_description(subject_node_dsl, description)
        return tokens
1015865
def _parse_code(self, line):
        
        log.debug("*** parse CODE: >>>%r<<<", line)
        parts = self.regex_split_all.split(line, maxsplit=1)
        if len(parts) == 1:  # end
            self.line_data.append(BASIC_Code(parts[0]))
            return
        pre, match, post = parts
        log.debug("\tpre: >>>%r<<<", pre)
        log.debug("\tmatch: >>>%r<<<", match)
        log.debug("\tpost: >>>%r<<<", post)

        if match == '"':
            log.debug("%r --> parse STRING", match)
            self.line_data.append(BASIC_Code(pre))
            string_part, rest = self._parse_string(post)
            self.line_data.append(BASIC_String(match + string_part))
            if rest:
                self._parse_code(rest)
            return

        self.line_data.append(BASIC_Code(pre + match))

        if match == "DATA":
            log.debug("%r --> parse DATA", match)
            data_part, rest = self._parse_data(post)
            self.line_data.append(BASIC_Data(data_part))
            if rest:
                self._parse_code(rest)
            return
        elif match in ("'", "REM"):
            log.debug("%r --> consume rest of the line as COMMENT", match)
            if post:
                self.line_data.append(BASIC_Comment(post))
            return

        raise RuntimeError("Wrong Reg.Exp.? match is: %r" % match)
899662
def tree(string, token=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]):
    
    return Text(string, token)
815157
def line_parse(validated_line)
      return unless validated_line
      row = validated_line.split(',')
      return unless row.any?
      if @headers.empty?
        @headers = row
      else
        @data_hash.merge!(row_to_hsh(row))
        @valid_rows << @data_hash
      end
    end
100595
def _load_multilinestring(tokens, string):
    
    open_paren = next(tokens)
    if not open_paren == '(':
        raise ValueError(INVALID_WKT_FMT % string)

    linestrs = []
    while True:
        try:
            linestr = _load_linestring(tokens, string)
            linestrs.append(linestr['coordinates'])
            t = next(tokens)
            if t == ')':
                # we're done; no more linestrings.
                break
        except StopIteration:
            # If we reach this, the WKT is not valid.
            raise ValueError(INVALID_WKT_FMT % string)

    return dict(type='MultiLineString', coordinates=linestrs)
1103130
def readline(self):
        
        data = self._file.readline()
        s = self.parse(data)
        return s