Siblings Identifiers of the passage

        :rtype: (str, str)
496894
def siblingsId(self) -> Tuple[CtsReference, CtsReference]:
        
        self._raise_depth()

        if not self._text:
            raise MissingAttribute("CapitainsCtsPassage was initiated without CtsTextMetadata object")
        if self._prev_next:
            return self._prev_next

        document_references = self._text.getReffs(level=self.depth)

        if self.reference.is_range():
            start, end = self.reference.start, self.reference.end
            range_length = len(self.getReffs(level=0))
        else:
            start = end = self.reference.start
            range_length = 1

        start = document_references.index(start)
        end = document_references.index(end)

        if start == 0:
            # If the passage is already at the beginning
            _prev = None
        elif start - range_length < 0:
            if start == end:
                _prev = document_references[0]
            else:
                _prev = "{}-{}".format(document_references[0], document_references[start-1])
        else:
            if start == end:
                _prev = document_references[start-1]
            else:
                _prev = "{}-{}".format(document_references[start-range_length], document_references[start-1])

        if start + 1 == len(document_references) or end + 1 == len(document_references):
            # If the passage is already at the end
            _next = None
        elif end + range_length > len(document_references):
            if start == end:
                _next = document_references[-1]
            else:
                _next = "{}-{}".format(document_references[end+1], document_references[-1])
        else:
            if start == end:
                _next = document_references[end+1]
            else:
                _next = "{}-{}".format(document_references[end+1], document_references[end + range_length])

        self._prev_next = (CtsReference(_prev), CtsReference(_next))
        return self._prev_next
202529
def siblings(self, as_resources=False):

		'''
		
		'''

		siblings = set()

		# loop through parents and get children
		for parent in self.parents(as_resources=True):
			for sibling in parent.children(as_resources=as_resources):
				siblings.add(sibling)

		# remove self
		if as_resources:
			siblings.remove(self)
		if not as_resources:
			siblings.remove(self.uri)

		return list(siblings)
834101
def siblings(self, node):
        
        # We need to read the _cte_node_parent* attributes, so ensure they
        # exist.
        self._ensure_parameters()
        # We need to construct: filter(parent = node.parent_id)
        return self.filter(
            **{
                self.model._cte_node_parent: getattr(
                    node, self.model._cte_node_parent_attname
                )
            }
        ).exclude(id=node.id)
530854
def _parse_study(self, fname, node_types):
        
        if not os.path.exists(os.path.join(self._dir, fname)):
            return None
        nodes = {}
        with open(os.path.join(self._dir, fname), "rU") as in_handle:
            reader = csv.reader(in_handle, dialect="excel-tab")
            header = self._swap_synonyms(next(reader))
            hgroups = self._collapse_header(header)
            htypes = self._characterize_header(header, hgroups)

            for node_type in node_types:
                try:
                    name_index = header.index(node_type)
                except ValueError:
                    name_index = None

                if name_index is None:
                    #print "Could not find standard header name: %s in %s" \
                    #                        % (node_type, header)
                    continue

                in_handle.seek(0, 0)
                for line in reader:
                    name = line[name_index]
                    #to deal with same name used for different node types (e.g. Source Name and Sample Name using the same string)
                    node_index = self._build_node_index(node_type,name)
                    #skip the header line and empty lines
                    if name in header:
                        continue
                    if (not name):
                        continue
                    try:
                        node = nodes[node_index]
                    except KeyError:
                        #print("creating node ", name, "  index", node_index)
                        node = NodeRecord(name, node_type)
                        node.metadata = collections.defaultdict(set)
                        nodes[node_index] = node
                        attrs = self._line_keyvals(line, header, hgroups, htypes, node.metadata)
                        nodes[node_index].metadata = attrs

        return dict([(k, self._finalize_metadata(v)) for k, v in nodes.items()])
1363518
def prev_sibling(self):
        
        if self.parent is None:
            return None

        # Can't use index(); we need to test by identity
        for i, child in enumerate(self.parent.children):
            if child is self:
                if i == 0:
                    return None
                return self.parent.children[i-1]
670549
def siblings(self):
        
        impl_nodelist = self.adapter.get_node_children(self.parent.impl_node)
        return self._convert_nodelist(
            [n for n in impl_nodelist if n != self.impl_node])
33489
def _parse_sibling(self, sibling, headers, data):
        

        sibling.exists = True

        # Parse the headers...
        for header, value in headers:
            header = header.lower()
            if header == 'content-type':
                sibling.content_type, sibling.charset = \
                    self._parse_content_type(value)
            elif header == 'etag':
                sibling.etag = value
            elif header == 'link':
                sibling.links = self._parse_links(value)
            elif header == 'last-modified':
                sibling.last_modified = mktime_tz(parsedate_tz(value))
            elif header.startswith('x-riak-meta-'):
                metakey = header.replace('x-riak-meta-', '')
                sibling.usermeta[metakey] = value
            elif header.startswith('x-riak-index-'):
                field = header.replace('x-riak-index-', '')
                reader = csv.reader([value], skipinitialspace=True)
                for line in reader:
                    for token in line:
                        token = decode_index_value(field, token)
                        sibling.add_index(field, token)
            elif header == 'x-riak-deleted':
                sibling.exists = False

        sibling.encoded_data = data

        return sibling
795392
def convert_examples_to_features(examples, label_list, max_seq_length,
                                 tokenizer, output_mode):
    """"""

    label_map = {label : i for i, label in enumerate(label_list)}

    features = []
    for (ex_index, example) in enumerate(examples):
        if ex_index % 10000 == 0:
            logger.info("Writing example %d of %d" % (ex_index, len(examples)))

        tokens_a = tokenizer.tokenize(example.text_a)

        tokens_b = None
        if example.text_b:
            tokens_b = tokenizer.tokenize(example.text_b)
            # Modifies `tokens_a` and `tokens_b` in place so that the total
            # length is less than the specified length.
            # Account for [CLS], [SEP], [SEP] with "- 3"
            _truncate_seq_pair(tokens_a, tokens_b, max_seq_length - 3)
        else:
            # Account for [CLS] and [SEP] with "- 2"
            if len(tokens_a) > max_seq_length - 2:
                tokens_a = tokens_a[:(max_seq_length - 2)]

        # The convention in BERT is:
        # (a) For sequence pairs:
        #  tokens:   [CLS] is this jack ##son ##ville ? [SEP] no it is not . [SEP]
        #  type_ids: 0   0  0    0    0     0       0 0    1  1  1  1   1 1
        # (b) For single sequences:
        #  tokens:   [CLS] the dog is hairy . [SEP]
        #  type_ids: 0   0   0   0  0     0 0
        #
        # Where "type_ids" are used to indicate whether this is the first
        # sequence or the second sequence. The embedding vectors for `type=0` and
        # `type=1` were learned during pre-training and are added to the wordpiece
        # embedding vector (and position vector). This is not *strictly* necessary
        # since the [SEP] token unambiguously separates the sequences, but it makes
        # it easier for the model to learn the concept of sequences.
        #
        # For classification tasks, the first vector (corresponding to [CLS]) is
        # used as as the "sentence vector". Note that this only makes sense because
        # the entire model is fine-tuned.
        tokens = ["[CLS]"] + tokens_a + ["[SEP]"]
        segment_ids = [0] * len(tokens)

        if tokens_b:
            tokens += tokens_b + ["[SEP]"]
            segment_ids += [1] * (len(tokens_b) + 1)

        input_ids = tokenizer.convert_tokens_to_ids(tokens)

        # The mask has 1 for real tokens and 0 for padding tokens. Only real
        # tokens are attended to.
        input_mask = [1] * len(input_ids)

        # Zero-pad up to the sequence length.
        padding = [0] * (max_seq_length - len(input_ids))
        input_ids += padding
        input_mask += padding
        segment_ids += padding

        assert len(input_ids) == max_seq_length
        assert len(input_mask) == max_seq_length
        assert len(segment_ids) == max_seq_length

        if output_mode == "classification":
            label_id = label_map[example.label]
        elif output_mode == "regression":
            label_id = float(example.label)
        else:
            raise KeyError(output_mode)

        if ex_index < 5:
            logger.info("*** Example ***")
            logger.info("guid: %s" % (example.guid))
            logger.info("tokens: %s" % " ".join(
                    [str(x) for x in tokens]))
            logger.info("input_ids: %s" % " ".join([str(x) for x in input_ids]))
            logger.info("input_mask: %s" % " ".join([str(x) for x in input_mask]))
            logger.info(
                    "segment_ids: %s" % " ".join([str(x) for x in segment_ids]))
            logger.info("label: %s (id = %d)" % (example.label, label_id))

        features.append(
                InputFeatures(input_ids=input_ids,
                              input_mask=input_mask,
                              segment_ids=segment_ids,
                              label_id=label_id))
    return features
853101
def siblingsId(self):
        
        if self._next_id is False or self._prev_id is False:
            self._prev_id, self._next_id = self.getPrevNextUrn(reference=self.urn.reference)
        return self._prev_id, self._next_id
593707
def _parse_header_id(line):
    
    if type(line) is not binary_type:
        raise TypeError("Expected header line to be of type %s but got %s" % (
            binary_type, type(line)))

    if len(line) <= 1:
        raise ValueError("No identifier on FASTA line")

    # split line at first space to get the unique identifier for
    # this sequence
    space_index = line.find(b" ")
    if space_index >= 0:
        identifier = line[1:space_index]
    else:
        identifier = line[1:]

    # annoyingly Ensembl83 reformatted the transcript IDs of its
    # cDNA FASTA to include sequence version numbers
    # .e.g.
    # "ENST00000448914.1" instead of "ENST00000448914"
    # So now we have to parse out the identifier
    dot_index = identifier.find(b".")
    if dot_index >= 0:
        identifier = identifier[:dot_index]

    return identifier.decode("ascii")
848423
def get_siblings(self):
        
        if self.parent:
            return get_result_class(self.__class__).objects.filter(
                parent=self.parent)
        return self.__class__.get_root_nodes()
66224
def strand_unknown(db, transcript):
    
    features = list(db.children(transcript))
    strand = features[0].strand
    if strand == ".":
        return True
    else:
        return False
50713
def to_madeline(self):
        
        
        madeline_header = [
            'FamilyID', 
            'IndividualID', 
            'Gender', 
            'Father', 
            'Mother', 
            'Affected',
            'Proband',
            'Consultand',
            'Alive'
        ]
        
        yield '\t'.join(madeline_header)
        
        for family_id in self.families:
            for individual_id in self.families[family_id].individuals:
                individual = self.families[family_id].individuals[individual_id]
                
                yield individual.to_madeline()
1265268
def strlib_unary_features(span):
    
    if not span.sentence.is_structural():
        return

    yield f"TAG_{get_tag(span)}", DEF_VALUE

    for attr in get_attributes(span):
        yield f"HTML_ATTR_{attr}", DEF_VALUE

    yield f"PARENT_TAG_{get_parent_tag(span)}", DEF_VALUE

    prev_tags = get_prev_sibling_tags(span)
    if len(prev_tags):
        yield f"PREV_SIB_TAG_{prev_tags[-1]}", DEF_VALUE
        yield f"NODE_POS_{len(prev_tags) + 1}", DEF_VALUE
    else:
        yield "FIRST_NODE", DEF_VALUE

    next_tags = get_next_sibling_tags(span)
    if len(next_tags):
        yield f"NEXT_SIB_TAG_{next_tags[0]}", DEF_VALUE
    else:
        yield "LAST_NODE", DEF_VALUE

    yield f"ANCESTOR_CLASS_[{' '.join(get_ancestor_class_names(span))}]", DEF_VALUE

    yield f"ANCESTOR_TAG_[{' '.join(get_ancestor_tag_names(span))}]", DEF_VALUE

    yield f"ANCESTOR_ID_[{' '.join(get_ancestor_id_names(span))}]", DEF_VALUE
84136
def with_siblings(graph, outputs):
    """"""
    siblings = set()
    for node in outputs:
        siblings |= graph.siblings(node)
    return siblings
1366085
def _init_entri(self, laman):
        

        sup = BeautifulSoup(laman.text, 'html.parser')
        estr = ''
        for label in sup.find('hr').next_siblings:
            if label.name == 'hr':
                self.entri.append(Entri(estr))
                break
            if label.name == 'h2':
                if estr:
                    self.entri.append(Entri(estr))
                estr = ''
            estr += str(label).strip()
900487
def word2id(self, xs):
        
        if isinstance(xs, list):
            return [self._word2id.get(x, self.UNK) for x in xs]
        return self._word2id.get(xs, self.UNK)