英文单词识别
@param text 识别文本
@param start 待识别文本开始索引
@param len 识别长度
@return 是否识别
773148
public static boolean isEnglish(final String text, final int start, final int len){
        for(int i=start; i<start+len; i++){
            char c = text.charAt(i);
            if(!isEnglish(c)){
                return false;
            }
        }
        //指定的字符串已经识别为英文串
        //下面要判断英文串是否完整
        if(start>0){
            //判断前一个字符，如果为英文字符则识别失败
            char c = text.charAt(start-1);
            if(isEnglish(c)){
                return false;
            }
        }
        if(start+len < text.length()){
            //判断后一个字符，如果为英文字符则识别失败
            char c = text.charAt(start+len);
            if(isEnglish(c)){
                return false;
            }
        }
        if(LOGGER.isDebugEnabled()) {
            LOGGER.debug("识别出英文单词：" + text.substring(start, start + len));
        }
        return true;
    }
1364626
public void setTextWithoutAnimation(char[] text, int start, int len) {
        mSkipAnimation = true;
        mEditText.setText(text, start, len);
    }
592609
public boolean startsWith(CharSequence text)
    {
        try
        {
            if (text.length() == 0)
            {
                if (acceptEmpty)
                {
                    return true;
                }
                else
                {
                    throw new SyntaxErrorException("empty string not accepted");
                }
            }
            InputReader reader = Input.getInstance(text);
            return startsWith(reader);
        }
        catch (IOException ex)
        {
            throw new IllegalArgumentException("can't happen");
        }
    }
936950
def len(self, text):
        
        if not isinstance(text, str):
            return len(text)

        return sum(self._EAW_MAP.get(east_asian_width(c), self.ambiguous_width)
                   for c in text)
681013
public static String wordWrap(final String value, final int len)
    {
        if (len < 0 || value.length() <= len)
            return value;

        BreakIterator bi = BreakIterator.getWordInstance(currentLocale());
        bi.setText(value);

        return value.substring(0, bi.following(len));
    }
816940
public Object parseText(String text) {
        if (text == null || "".equals(text)) {
            throw new IllegalArgumentException("Text must not be null");
        }
        return createParser().parse(text);
    }
745773
public static String getBrief(String str, int len, char c) {
		if (str == null)
			return "";
		if (str.length() < len)
			return str;
		return new StringBuffer(str.substring(0, len - 3)).append(c).append(c)
				.append(c).toString();
	}
472963
@Override
    public boolean hasNext(int startPosition, int contentLength) {
        char ch = nextGoodChar();
        if (ch == ',') return true;
        if (ch == '}' || ch == ']' || ch == 0) return false;
        backChar(ch); // { [ 交由 readObjectB 或 readMapB 或 readArrayB 读取
        return true;
    }
1206439
public static List<List<Term>> seg2sentence(String text)
    {
        List<List<Term>> sentenceList = SEGMENT.seg2sentence(text);
        for (List<Term> sentence : sentenceList)
        {
            ListIterator<Term> listIterator = sentence.listIterator();
            while (listIterator.hasNext())
            {
                if (!CoreStopWordDictionary.shouldInclude(listIterator.next()))
                {
                    listIterator.remove();
                }
            }
        }

        return sentenceList;
    }
480156
public String decryptText(String text)
	throws Exception
	{
		return new String(this.decrypt(toBytesFromByteText(text)), IO.CHARSET);

	}
991822
public static boolean isQuantifier(final String text, final int start, final int len){
        if(len < 2){
            return false;
        }
        //避免量词和不完整小数结合
        //.的值是46,/的值是47
        //判断前一个字符是否是.或/
        int index = start-1;
        if(index > -1 && (text.charAt(index) == 46 || text.charAt(index) == 47)){
            return false;
        }
        char lastChar = text.charAt(start+len-1);
        if(Quantifier.is(lastChar)
                && 
                (isNumber(text, start, len-1) || 
                isChineseNumber(text, start, len-1) || 
                isFraction(text, start, len-1)) ){
            if(LOGGER.isDebugEnabled()) {
                LOGGER.debug("识别数量词：" + text.substring(start, start + len));
            }
            return true;
        }
        return false;
    }
1375064
def segment(self, text, lower=True, use_stop_words=True, use_speech_tags_filter=False):
        
        jieba_result = cut_for_search(text)
        jieba_result = [w for w in jieba_result]

        # 去除特殊符号
        word_list = [w.strip() for w in jieba_result]
        word_list = [word for word in word_list if len(word) > 0]

        if use_speech_tags_filter == False:
            jieba_result = [w for w in jieba_result]

        if lower:
            word_list = [word.lower() for word in word_list]

        if use_stop_words:
            word_list = [word.strip() for word in word_list if word.strip() not in self.stop_words]

        return word_list
691333
private List<String> fullSeg(final String text, final int start) {
        List<String> result = new LinkedList<>();
        final int textLen = text.length();
        //剩下文本长度
        int len = textLen - start;
        //最大截取长度
        int interceptLength = getInterceptLength();
        if(len > interceptLength){
            len = interceptLength;
        }
        while(len > 1){
            if(getDictionary().contains(text, start, len) || RecognitionTool.recog(text, start, len)){
                result.add(text.substring(start, start + len));
            }
            len--;
        }
        if(textLen <= CHAR_IS_WORD_LENGTH_LESS_THAN || result.isEmpty()){
            //增加单字词
            result.add(text.substring(start, start + 1));
        }
        return result;
    }
783623
public void writeCharacters(char[] text, int start, int len)
			throws XMLStreamException {
		this.writeCharacters(new String(text, start, len));
	}
1193123
public List<String> matchAll(String text, int limit, boolean isDensityMatch, boolean isGreedMatch) {
		if(null == text){
			return null;
		}
		
		List<String> findedWords = new ArrayList<String>();
		WordTree current = this;
		int length = text.length();
		StringBuilder wordBuffer;//存放查找到的字符缓存。完整出现一个词时加到findedWords中，否则清空
		char currentChar;
		for (int i = 0; i < length; i++) {
			wordBuffer = StrUtil.builder();
			for (int j = i; j < length; j++) {
				currentChar = text.charAt(j);
//				Console.log("i: {}, j: {}, currentChar: {}", i, j, currentChar);
				if(StopChar.isStopChar(currentChar)){
					if(wordBuffer.length() > 0){
						//做为关键词中间的停顿词被当作关键词的一部分被返回
						wordBuffer.append(currentChar);
					}else{
						//停顿词做为关键词的第一个字符时需要跳过
						i++;
					}
					continue;
				}else if(false == current.containsKey(currentChar)){
					//非关键字符被整体略过，重新以下个字符开始检查
					break;
				}
				wordBuffer.append(currentChar);
				if(current.isEnd(currentChar)){
					//到达单词末尾，关键词成立，从此词的下一个位置开始查找
					findedWords.add(wordBuffer.toString());
					if(limit > 0 && findedWords.size() >= limit){
						//超过匹配限制个数，直接返回
						return findedWords;
					}
					if(false == isDensityMatch){
						//如果非密度匹配，跳过匹配到的词
						i = j;
					}
					if(false == isGreedMatch){
						//如果懒惰匹配（非贪婪匹配）。当遇到第一个结尾标记就结束本轮匹配
						break;
					}
				}
				current = current.get(currentChar);
				if(null == current){
					break;
				}
			}
			current = this;
		}
		return findedWords;
	}
478832
public static Config newConfigFromText(String text) {
        Config c = new Config();
        c.parseBuffer(new BufferedReader(new StringReader(text)));
        return c;
    }
1069207
public List<Term> seg(String text)
    {
        char[] charArray = text.toCharArray();
        if (HanLP.Config.Normalization)
        {
            CharTable.normalization(charArray);
        }
        if (config.threadNumber > 1 && charArray.length > 10000)    // 小文本多线程没意义，反而变慢了
        {
            List<String> sentenceList = SentencesUtil.toSentenceList(charArray);
            String[] sentenceArray = new String[sentenceList.size()];
            sentenceList.toArray(sentenceArray);
            //noinspection unchecked
            List<Term>[] termListArray = new List[sentenceArray.length];
            final int per = sentenceArray.length / config.threadNumber;
            WorkThread[] threadArray = new WorkThread[config.threadNumber];
            for (int i = 0; i < config.threadNumber - 1; ++i)
            {
                int from = i * per;
                threadArray[i] = new WorkThread(sentenceArray, termListArray, from, from + per);
                threadArray[i].start();
            }
            threadArray[config.threadNumber - 1] = new WorkThread(sentenceArray, termListArray, (config.threadNumber - 1) * per, sentenceArray.length);
            threadArray[config.threadNumber - 1].start();
            try
            {
                for (WorkThread thread : threadArray)
                {
                    thread.join();
                }
            }
            catch (InterruptedException e)
            {
                logger.severe("线程同步异常：" + TextUtility.exceptionToString(e));
                return Collections.emptyList();
            }
            List<Term> termList = new LinkedList<Term>();
            if (config.offset || config.indexMode > 0)  // 由于分割了句子，所以需要重新校正offset
            {
                int sentenceOffset = 0;
                for (int i = 0; i < sentenceArray.length; ++i)
                {
                    for (Term term : termListArray[i])
                    {
                        term.offset += sentenceOffset;
                        termList.add(term);
                    }
                    sentenceOffset += sentenceArray[i].length();
                }
            }
            else
            {
                for (List<Term> list : termListArray)
                {
                    termList.addAll(list);
                }
            }

            return termList;
        }
//        if (text.length() > 10000)  // 针对大文本，先拆成句子，后分词，避免内存峰值太大
//        {
//            List<Term> termList = new LinkedList<Term>();
//            if (config.offset || config.indexMode)
//            {
//                int sentenceOffset = 0;
//                for (String sentence : SentencesUtil.toSentenceList(charArray))
//                {
//                    List<Term> termOfSentence = segSentence(sentence.toCharArray());
//                    for (Term term : termOfSentence)
//                    {
//                        term.offset += sentenceOffset;
//                        termList.add(term);
//                    }
//                    sentenceOffset += sentence.length();
//                }
//            }
//            else
//            {
//                for (String sentence : SentencesUtil.toSentenceList(charArray))
//                {
//                    termList.addAll(segSentence(sentence.toCharArray()));
//                }
//            }
//
//            return termList;
//        }
        return segSentence(charArray);
    }