Encode a single sentence.
518380
def encode_sentence(sentence):
    """"""
    tree = etree.Element('sentence')
    encode_infons(tree, sentence.infons)
    etree.SubElement(tree, 'offset').text = str(sentence.offset)
    if sentence.text:
        etree.SubElement(tree, 'text').text = sentence.text
    for ann in sentence.annotations:
        tree.append(encode_annotation(ann))
    for rel in sentence.relations:
        tree.append(encode_relation(rel))
    return tree
160301
def dm_encode(keypad_area, clear, beep, timeout, line1, line2):
    """"""
    return MessageEncode(
        '2Edm{:1d}{:1d}{:1d}{:05d}{:^<16.16}{:^<16.16}00'
        .format(keypad_area+1, clear, beep, timeout, line1, line2), None
    )
1215587
def encode_sentence(obj):
    """"""
    warnings.warn("deprecated. Please use bioc.biocxml.encoder.encode_sentence", DeprecationWarning)
    return bioc.biocxml.encoder.encode_sentence(obj)
128109
def cut(sentence, HMM=True):
    
    global dt
    if jieba.pool is None:
        for w in dt.cut(sentence, HMM=HMM):
            yield w
    else:
        parts = strdecode(sentence).splitlines(True)
        if HMM:
            result = jieba.pool.map(_lcut_internal, parts)
        else:
            result = jieba.pool.map(_lcut_internal_no_hmm, parts)
        for r in result:
            for w in r:
                yield w
662925
def encode_passage(passage):
    """"""
    tree = etree.Element('passage')
    encode_infons(tree, passage.infons)
    etree.SubElement(tree, 'offset').text = str(passage.offset)
    if passage.text:
        etree.SubElement(tree, 'text').text = passage.text
    for sen in passage.sentences:
        tree.append(encode_sentence(sen))
    for ann in passage.annotations:
        tree.append(encode_annotation(ann))
    for rel in passage.relations:
        tree.append(encode_relation(rel))
    return tree
570536
def rem_encoding(code):
    """"""
    old_lines = code.splitlines()
    new_lines = []
    for i in range(min(2, len(old_lines))):
        line = old_lines[i]
        if not (line.lstrip().startswith("#") and "coding" in line):
            new_lines.append(line)
    new_lines += old_lines[2:]
    return "\n".join(new_lines)
1036423
def make_sentence(sentence, *args, **kwargs):
    
    return symbols.SENTENCE(*([sentence] + list(args)), **kwargs)
214226
def sentence_bytes(self, sentence):
        
        result = [TOKENS[sentence[0]]]

        for i in sentence[1:]:  # Remaining bytes
            if isinstance(i, str):
                result.extend(self.literal(i))
            elif isinstance(i, float) or isinstance(i, int):  # A number?
                result.extend(self.number(i))
            else:
                result.extend(i)  # Must be another thing

        return result
1248358
def encode(cls, line):
        
        if not line.encoded:
            encoding = getattr(line, 'encoding_param', None)
            if encoding and encoding.upper() == cls.base64string:
                if isinstance(line.value, bytes):
                    line.value = codecs.encode(line.value, "base64").decode("utf-8").replace('\n', '')
                else:
                    line.value = codecs.encode(line.value.encode(encoding), "base64").decode("utf-8")
            else:
                line.value = backslashEscape(line.value)
            line.encoded = True
276466
def encode_simple(d):
    """"""
    if isinstance(d, unicode):
        return d.encode()
    if isinstance(d, list):
        return list(map(encode_simple, d))
    if isinstance(d, dict):
        return dict([(encode_simple(k), encode_simple(v)) for k, v in d.items()])
    return d
301951
public static String encodeText(String text, Charset charset) {
		try {
			return MimeUtility.encodeText(text, charset.name(), null);
		} catch (UnsupportedEncodingException e) {
			// ignore
		}
		return text;
	}
344586
def stream(input, encoding=None, errors='strict'):
	
	
	input = (i for i in input if i)  # Omits `None` (empty wrappers) and empty chunks.
	
	if encoding:  # Automatically, and iteratively, encode the text if requested.
		input = iterencode(input, encoding, errors=errors)
	
	return input
846783
def cw_encode(index, value, value_format):
    """"""
    if value_format == 2:
        value = value[0] << 8 + value[1]
    return MessageEncode('0Dcw{:02d}{:05d}00'.format(index+1, value), None)
1065896
def encode(self, obj):
        """"""
        s = super(CustomEncoder, self).encode(obj)
        # If uncompressed, postprocess for formatting
        if len(s.splitlines()) > 1:
            s = self.postprocess(s)
        return s
376483
def _writeSentenceInBlock(sentence, blockID, sentenceID):
    ''''''
    with open("sentenceIDs.txt", "a") as fp:
        fp.write("sentenceID: "+str(blockID)+"_"+str(sentenceID)+"\n")
        fp.write("sentence string: "+sentence+"\n")
        fp.write("\n")
870197
def encode(arg, delimiter=None, encodeseq=None, encoded=tuple()):
    ''''''
    arg = coerce_unicode(arg, _c.FSQ_CHARSET)
    new_arg = sep = u''
    delimiter, encodeseq = delimiter_encodeseq(
        _c.FSQ_DELIMITER if delimiter is None else delimiter,
        _c.FSQ_ENCODE if encodeseq is None else encodeseq,
        _c.FSQ_CHARSET)

    # validate encoded tuple
    for enc in encoded:
        enc = coerce_unicode(enc, _c.FSQ_CHARSET)
        try:
            enc = enc.encode('ascii')
        except UnicodeEncodeError:
            raise FSQEncodeError(errno.EINVAL, u'invalid encoded value: {0}'\
                                 u' non-ascii'.format(enc))
    # char-wise encode walk
    for seq in arg:
        if seq == delimiter or seq == encodeseq or seq in _ENCODED + encoded:
            h_val = hex(ord(seq))
            # front-pad with zeroes
            if 3 == len(h_val):
                h_val = sep.join([h_val[:2], u'0', h_val[2:]])
            if 4 != len(h_val):
                raise FSQEncodeError(errno.EINVAL, u'invalid hex ({0}) for'\
                                     ' encode-target: {1}'.format(h_val, seq))
            seq = sep.join([encodeseq, h_val[2:]])

        new_arg = sep.join([new_arg, seq])

    return new_arg
1351013
def _byte_encode(self, token):
    """"""
    # Vocab ids for all bytes follow ids for the subwords
    offset = len(self._subwords)
    if token == "_":
      return [len(self._subwords) + ord(" ")]
    return [i + offset for i in list(bytearray(tf.compat.as_bytes(token)))]