Encode a single relation.
353958
def encode_relation(obj):
    """"""
    warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_relation", DeprecationWarning)
    return bioc.biocxml.encoder.encode_relation(obj)
152037
def from_first_relation(cls, vertex0, vertex1):
        """"""
        result = cls([(vertex0, vertex1)])
        result.previous_ends1 = set([vertex1])
        return result
714624
function encode(data, ch) {
        if (!self.utfMouse) {
          if (ch === 255) return data.push(0);
          if (ch > 127) ch = 127;
          data.push(ch);
        } else {
          if (ch === 2047) return data.push(0);
          if (ch < 127) {
            data.push(ch);
          } else {
            if (ch > 2047) ch = 2047;
            data.push(0xC0 | (ch >> 6));
            data.push(0x80 | (ch & 0x3F));
          }
        }
      }
1197551
def to_internal_value_single(self, data, serializer):
        """"""
        related_model = serializer.Meta.model
        if isinstance(data, related_model):
            return data
        try:
            instance = related_model.objects.get(pk=data)
        except related_model.DoesNotExist:
            raise ValidationError(
                "Invalid value for '%s': %s object with ID=%s not found" %
                (self.field_name, related_model.__name__, data)
            )
        return instance
527553
def encode_document(document):
    """"""
    tree = etree.Element('document')
    etree.SubElement(tree, 'id').text = document.id
    encode_infons(tree, document.infons)
    for passage in document.passages:
        tree.append(encode_passage(passage))
    for ann in document.annotations:
        tree.append(encode_annotation(ann))
    for rel in document.relations:
        tree.append(encode_relation(rel))
    return tree
143563
def _encode_mapping(mapping, f):
	""""""
	f.write(_TYPE_DICT)
	for key, value in sorted(mapping.items()):
		_encode_buffer(key, f)
		bencode(value, f)
	f.write(_TYPE_END)
943017
def encode1(self):
        """"""
        data_uri = b64encode(open(self.path, 'rb').read()).decode('utf-8').replace('\n', '')
        return '<img src="data:image/png;base64,{0}">'.format(data_uri)
1042014
def _encode_data(data):
        """"""
        data = data if data is not None else {}
        data = to_nested_php_args(data)
        files = dict([
            (key, value) for key, value in
            data.items() if isinstance(value, file_type)])
        for fname in files:
            del data[fname]
        return data, files or None, None
826356
def encode(self, input_str):
    """"""
    inputs = self.encoders["inputs"].encode(input_str) + [EOS_ID]
    batch_inputs = np.reshape(inputs, [1, -1, 1, 1])  # Make it 3D.
    return batch_inputs
1283438
def concat(self, other, inplace=False):
        ''''''
        
        # Create new entity
        if inplace:
            obj = self
        else:
            obj = self.copy()
        
        # Stitch every attribute
        for name, attr in obj.__attributes__.items():
            attr.append(other.__attributes__[name])
            
        # Stitch every relation
        for name, rel in obj.__relations__.items():
            rel.append(other.__relations__[name])
        
        # Update maps
        
        # Update dimensions
        if obj.is_empty():
            obj.maps = {k: m.copy() for k, m in other.maps.items()}
            obj.dimensions = other.dimensions.copy()
        else:
            for (a, b), rel in obj.maps.items():
                rel.append(other.maps[a, b])
            for d in obj.dimensions:
                obj.dimensions[d] += other.dimensions[d]
        
        return obj
160462
def dump_type(self, obj):
        """"""
        if not isinstance(obj.relation_type, RelationType):
            return resolve_relation_type_config(obj.relation_type).name
        else:
            return obj.relation_type.name
190277
def _map_relation(c, language='any'):
    
    label = c.label(language)
    return {
        'id': c.id,
        'type': c.type,
        'uri': c.uri,
        'label': label.label if label else None
    }
77407
def _handle_relation(self, tokens: ParseResults) -> str:
        """"""
        subject_node_dsl = self.ensure_node(tokens[SUBJECT])
        object_node_dsl = self.ensure_node(tokens[OBJECT])

        subject_modifier = modifier_po_to_dict(tokens[SUBJECT])
        object_modifier = modifier_po_to_dict(tokens[OBJECT])

        annotations = {
            annotation_name: (
                {
                    ae: True
                    for ae in annotation_entry
                }
                if isinstance(annotation_entry, set) else
                {
                    annotation_entry: True
                }
            )
            for annotation_name, annotation_entry in self.control_parser.annotations.items()
        }

        return self._add_qualified_edge(
            subject_node_dsl,
            object_node_dsl,
            relation=tokens[RELATION],
            annotations=annotations,
            subject_modifier=subject_modifier,
            object_modifier=object_modifier,
        )
10272
private static ImmutableSet<RelationID> attributeOccurrencesUnion(QuotedID id,
                                                                      RAExpressionAttributes re1,
                                                                      RAExpressionAttributes re2) {

        ImmutableSet<RelationID> s1 = re1.attributeOccurrences.get(id);
        ImmutableSet<RelationID> s2 = re2.attributeOccurrences.get(id);

        if (s1 == null)
            return s2;

        if (s2 == null)
            return s1;

        return ImmutableSet.<RelationID>builder().addAll(s1).addAll(s2).build();
    }
170615
def _encode_mapping(name, value, check_keys, opts):
    """"""
    data = b"".join([_element_to_bson(key, val, check_keys, opts)
                     for key, val in iteritems(value)])
    return b"\x03" + name + _PACK_INT(len(data) + 5) + data + b"\x00"
1001441
function encode (nameOrCode, buf) {
  const base = getBase(nameOrCode)
  const name = base.name

  return multibase(name, Buffer.from(base.encode(buf)))
}
658160
def _encode_target(data, target, mapping=None):
    
    if mapping is None:
        mapping = {t: i for i, t in enumerate(sorted(data[target].unique()))}

    data[target] = data[target].apply(lambda t: mapping[t])
    return data, mapping