convert from Arabic Presentation Forms B
323374
function convertArabicBack(apfb) {
	var toReturn = "",
		selectedChar;
	
	theLoop:
	for( var i = 0 ; i < apfb.length ; ++i ) {
		selectedChar = apfb.charCodeAt(i);

		for( var j = 0 ; j < charsMap.length ; ++j ) {
			if( charsMap[j][4] == selectedChar || charsMap[j][2] == selectedChar || 
				charsMap[j][1] == selectedChar || charsMap[j][3] == selectedChar ) {
				toReturn += String.fromCharCode(charsMap[j][0]);
				continue theLoop;
			}
		}

		for( var j = 0 ; j < combCharsMap.length ; ++j ) {
			if( combCharsMap[j][4] == selectedChar || combCharsMap[j][2] == selectedChar || 
				combCharsMap[j][1] == selectedChar || combCharsMap[j][3] == selectedChar ) {
				toReturn += String.fromCharCode(combCharsMap[j][0][0]) + String.fromCharCode(combCharsMap[j][0][1]);
				continue theLoop;
			}
		}

		toReturn += String.fromCharCode( selectedChar );
	}
	return toReturn;
}
532194
def convert(document):
    """"""
    raw_tokens = []
    curpos = 0
    text_spans = []
    all_labels = []
    sent_spans = []
    word_texts = []
    for sentence in document:
        startpos = curpos
        for idx, (text, label) in enumerate(sentence):
            raw_tokens.append(text)
            word_texts.append(text)
            all_labels.append(label)
            text_spans.append((curpos, curpos+len(text)))
            curpos += len(text)
            if idx < len(sentence) - 1:
                raw_tokens.append(' ')
                curpos += 1
        sent_spans.append((startpos, curpos))
        raw_tokens.append('\n')
        curpos += 1
    return {
        TEXT: ''.join(raw_tokens),
        WORDS: [{TEXT: text, START: start, END: end, LABEL: label} for text, (start, end), label in zip(word_texts, text_spans, all_labels)],
        SENTENCES: [{START: start, END:end} for start, end in sent_spans]
    }
584503
def translate(src, dest, word):
	'''  '''

	results = []

	try:
		from textblob import TextBlob
		results.append(TextBlob(word).translate(from_lang = src, to = dest).string)
	except ImportError:
		pass

	if not results:
		return [None]
	return results
1243403
def _convert_strls(self, data):
        """"""
        convert_cols = [
            col for i, col in enumerate(data)
            if self.typlist[i] == 32768 or col in self._convert_strl]

        if convert_cols:
            ssw = StataStrLWriter(data, convert_cols)
            tab, new_data = ssw.generate_table()
            data = new_data
            self._strl_blob = ssw.generate_blob(tab)
        return data
1353252
async def blob(self, elem=None, elem_type=None, params=None):
        
        elem_type = elem_type if elem_type else elem.__class__
        if hasattr(elem_type, 'kv_serialize'):
            elem = elem_type() if elem is None else elem
            return await elem.kv_serialize(self, elem=elem, elem_type=elem_type, params=params)

        if self.writing:
            elem_is_blob = isinstance(elem, x.BlobType)
            data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem
            if data is None:
                return NoSetSentinel()
            if len(data) == 0:
                return b''

            fval = Modeler.to_bytes(data)
            if self.hexlify:
                return binascii.hexlify(fval).decode('ascii')
            else:
                return fval

        else:
            if elem is None:
                return NoSetSentinel()
            if self.hexlify:
                return bytes(binascii.unhexlify(elem))
            else:
                return bytes(elem)
201205
def to_text(s, encoding="utf-8"):
    
    if isinstance(s, six.text_type):
        return s
    else:
        return six.binary_type(s).decode(encoding)
132822
def _convert_verbal_form( analysis ):
    '''  '''
    assert FORM in analysis, '(!) The input analysis does not contain "'+FORM+'" key.'
    for form, replacement in _verb_conversion_rules:
        # Exact match
        if analysis[FORM] == form:
           assert analysis[POSTAG] == 'V', \
               '(!) Expected analysis of verb, but got analysis of "'+str(analysis[POSTAG])+'" instead.'
           analysis[FORM] = replacement
        # Inclusion :   the case of some_prefix+' '+form ;
        elif analysis[FORM].endswith(' '+form):
           parts  = analysis[FORM].split()
           prefix = ' '.join( parts[:len(parts)-1] )
           analysis[FORM] = prefix+' '+replacement
    return analysis
150446
def translate_tab(data):
    
    tab_str = ""
    sections = data.get("Sections", [])
    for section in sections:
            print("  Translating " + section["Type"])
            tab_str += translate_map[section["Type"]](section)
    return tab_str
1062073
function getComputedTranslate(obj) {
        var result = {
            translateX: 0,
            translateY: 0,
            translateZ: 0,
            scaleX: 1,
            scaleY: 1,
            offsetX: 0,
            offsetY: 0
        };
        var offsetX = 0, offsetY = 0;
        if (!global.getComputedStyle || !obj) return result;
        var style = global.getComputedStyle(obj), transform, origin;
        transform = style.webkitTransform || style.mozTransform;
        origin = style.webkitTransformOrigin || style.mozTransformOrigin;
        var par = origin.match(/(.*)px\s+(.*)px/);
        if (par.length > 1) {
            offsetX = par[1] - 0;
            offsetY = par[2] - 0;
        }
        if (transform === 'none') return result;
        var mat3d = transform.match(/^matrix3d\((.+)\)$/);
        var mat2d = transform.match(/^matrix\((.+)\)$/);
        var str;
        if (mat3d) {
            str = mat3d[1].split(', ');
            result = {
                translateX: str[12] - 0,
                translateY: str[13] - 0,
                translateZ: str[14] - 0,
                offsetX: offsetX - 0,
                offsetY: offsetY - 0,
                scaleX: str[0] - 0,
                scaleY: str[5] - 0,
                scaleZ: str[10] - 0
            };
        } else if (mat2d) {
            str = mat2d[1].split(', ');
            result = {
                translateX: str[4] - 0,
                translateY: str[5] - 0,
                offsetX: offsetX - 0,
                offsetY: offsetY - 0,
                scaleX: str[0] - 0,
                scaleY: str[3] - 0
            };
        }
        return result;
    }
1032698
def to_ansi_24bit(self):
        
        text = self.text.replace('\x1b', '')
        if self.color and self.bg_color:
            c = self.color.scale(255)
            bg_c = self.bg_color.scale(255)
            return ansicolor(text,
                             fg=(c.r, c.g, c.b),
                             bg=(bg_c.r, bg_c.g, bg_c.b))
        elif self.color:
            c = self.color.scale(255)
            return ansicolor(text,
                             fg=(c.r, c.g, c.b))
        elif self.bg_color:
            bg_c = self.bg_color.scale(255)
            return ansicolor(text,
                             bg=(bg_c.r, bg_c.g, bg_c.b))
        else:
            return text
1223716
def convert(self, text, encoding):
        """"""

        if self.normalize in ('NFC', 'NFKC', 'NFD', 'NFKD'):
            text = unicodedata.normalize(self.normalize, text)
        if self.convert_encoding:
            text = text.encode(self.convert_encoding, self.errors).decode(self.convert_encoding)
            encoding = self.convert_encoding
        return text, encoding
727452
def detranslify(text):
    """"""
    try:
        res = translit.detranslify(text)
    except Exception as err:
        # because filter must die silently
        res = default_value % {'error': err, 'value': text}
    return res
317907
def convert()
      errors = ""
      output = ""
      
      if @user_pwd 
        cmd = "pdftohtml -stdout #{@format} -upw #{@user_pwd}" + ' "' + @path + '"'    
      elsif @owner_pwd 
        cmd = "pdftohtml -stdout #{@format} -opw #{@owner_pwd}" + ' "' + @path + '"'
      else
        cmd = "pdftohtml -stdout #{@format}" + ' "' + @path + '"'
      end
      
      output = `#{cmd} 2>&1`

      if (output.include?("Error: May not be a PDF file"))
        raise PDFToHTMLRError, "Error: May not be a PDF file (continuing anyway)"
      elsif (output.include?("Error:"))
        raise PDFToHTMLRError, output.split("\n").first.to_s.chomp
      else
        return output
      end
    end
709317
def to_unicode(value, encoding=None):
    
    if isinstance(value, text_type):
        return value
    elif isinstance(value, type(None)):
        return text_type(value)

    if not isinstance(value, bytes):
        raise TypeError(
            "Expected bytes, unicode, or None; got %r" % type(value)
        )

    if encoding is not None:
        return value.decode(encoding)
    else:
        try:
            value = value.decode('utf-8')
        except:
            try:
                value = value.decode('gbk')
            except:
                pass

        return value
593992
def to_array(self):
        
        array = super(InputMediaAnimation, self).to_array()
        array['type'] = u(self.type)  # py2: type unicode, py3: type str

        array['media'] = u(self.media)  # py2: type unicode, py3: type str

        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = self.thumb.to_array()  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if

        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str

        if self.parse_mode is not None:
            array['parse_mode'] = u(self.parse_mode)  # py2: type unicode, py3: type str

        if self.width is not None:
            array['width'] = int(self.width)  # type int
        if self.height is not None:
            array['height'] = int(self.height)  # type int
        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        return array
306927
def _convert_data(self, data, data_type, num_recs, num_values, num_elems):
        '''
        
        '''

        if (data_type == 51 or data_type == 52):
            return [data[i:i+num_elems].decode('utf-8') for i in
                    range(0, num_recs*num_values*num_elems, num_elems)]
        else:
            tofrom = self._convert_option()
            dt_string = self._convert_type(data_type)
            form = tofrom + str(num_recs*num_values*num_elems) + dt_string
            value_len = CDF._type_size(data_type, num_elems)
            return list(struct.unpack_from(form,
                                           data[0:num_recs*num_values*value_len]))
322543
def normalize_text_normal_ipadic(input_text, kana=True, ascii=True, digit=True):
    # type: (text_type,bool,bool,bool)->text_type
    
    return jaconv.h2z(input_text, kana=kana, ascii=ascii, digit=digit)