Tag (Latent Var) is Xi, words (Observed Var) yi (or oi) ...

@param data input sequence examples.
@return HMM model.
516798
public static HMMModel train(List<SequenceTuple> data) {
        HMMModel model = new HMMModel();

        for (SequenceTuple seqTuple : data) {
            Pair<List<String>, List<String>> wordTagPair = getXSeqOSeq(seqTuple);
            List<String> words = wordTagPair.getLeft();
            List<String> tag = wordTagPair.getRight();

            for (int i = 0; i < words.size(); i++) {
                Double ct = model.emission.get(words.get(i), tag.get(i));  // Oi, Xi
                ct = ct == null ? 1 : ct + 1;
                model.emission.put(words.get(i), tag.get(i), ct);
            }

            for (int i = 0; i < tag.size() - 1; i++) {  // Xi -> X_i+1
                Double ct = model.transition.get(tag.get(i), tag.get(i + 1));
                ct = ct == null ? 1 : ct + 1;
                model.transition.put(tag.get(i), tag.get(i + 1), ct);
            }
        }

        normalizeEmission(model);
        normalizeTrans(model);
        return model;
    }
696929
public static String genSequence6Tags(String[] wordArray){
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<wordArray.length; i++) {
			String word = wordArray[i];
			String tag = null;
			int len = word.length();
			switch(len){
			case 1:
				tag = "S";break;
			case 2:
				tag = "BE";break;
			case 3:
				tag = "B2E";break;
			case 4:
				tag = "B23E";break;
			default :
				tag = "B23";
				int rest = len-4;
				while(rest-->0){
					tag+="M";
				}
				tag+="E";
			}
			assert tag.length() ==len;
			for(int j=0; j<word.length(); j++) {
				char c = word.charAt(j);	
				sb.append(c);
				sb.append('\t');
				sb.append(tag.charAt(j));
				sb.append('\n');
			}
		}
		sb.append('\n');
		return sb.toString();
	}
616154
private String getNextTag(String str) {
        String tag;
        int endIndex;
        int tagIndex = str.indexOf("(");

        if( tagIndex < 0 ) {
            return null;
        }

        // in case there's nothing in the sentence
        endIndex = str.indexOf(" ", tagIndex);

        if( endIndex < 0 ) {
            return null;
        }

        tag = str.substring( tagIndex+1, endIndex ); 

        if( tag.length() > 0 ) {
            return tag;
        } else {
            str = str.substring( tagIndex+1 );
            return getNextTag(str);
        }
    }
973413
public String[][] tag(String input){
		if(pos==null||seg==null)
			return null;
		return pos.tag2Array(input);
	}
416954
@Override
  public List<TaggedWord> tag(String word) {
    List<TaggedWord> lookedUpTerms = mapping.get(word);
    if (lookedUpTerms != null) {
      return Collections.unmodifiableList(lookedUpTerms);
    } else {
      return Collections.emptyList();
    }
  }
596145
public static String toHexString(byte[] data) {
    StringBuilder sb = new StringBuilder(data.length * 2);
    for (byte element : data) {
      sb.append(Integer.toHexString((element >> 4) & 15));
      sb.append(Integer.toHexString(element & 15));
    }
    return sb.toString();
  }
260592
public static String getMimeType(final byte[] data) {
		String mimeType = null;
		try {
			mimeType = MimeUtil.getMagicMimeType(data);
		} catch (final Exception e) {
		} finally {
			if (mimeType == null) {
				mimeType = UNKNOWN_MIME_TYPE;
			}
		}
		return mimeType;
	}
1347447
function(data, vmodels) {
            var text = data.value.trim(),
                    simple = true
            if (text.indexOf(openTag) > -1 && text.indexOf(closeTag) > 2) {
                simple = false
                if (rexpr.test(text) && RegExp.rightContext === "" && RegExp.leftContext === "") {
                    simple = true
                    text = RegExp.$1
                }
            }
            data.handlerName = "attr" //handleName用于处理多种绑定共用同一种bindingExecutor的情况
            parseExprProxy(text, vmodels, data, (simple ? null : scanExpr(data.value)))
        }
997669
public static Map<String, Set<String>> parseAssignment(String data) {
        Map<String, Set<String>> ret = new HashMap<>();
        if (data != null) {
            StringTokenizer stringTokenizer = new StringTokenizer(data, String.format("%s%s%s", EQUALITY, COMMA, SEMICOLON), true);
            String key = null;
            Set<String> value = new HashSet<>();
            int counter = 0;
            while (stringTokenizer.hasMoreTokens()) {
                String token = stringTokenizer.nextToken();
                if (isValueDelimiter(token)) {
                    continue;
                } else if (isKeyDelimiter(token) && key != null) {
                    ret.put(key, value);
                    counter = 0;
                    key = null;
                    value = new HashSet<>();
                    continue;
                } else if (counter == 0) {
                    key = token.trim();
                } else {
                    String trimmedValue = token.trim();
                    if (!StringUtils.isEmpty(trimmedValue)) {
                        value.add(trimmedValue);
                    }
                }
                counter++;
            }
            if (key != null) {
                ret.put(key, value);
            }
        }
        return ret;
    }
750954
public void writeStringUTF8(String data) throws AsnException, IOException {

		this.writeStringUTF8(Tag.CLASS_UNIVERSAL, Tag.STRING_UTF8, data);
	}
994149
public String[] tag2Array(String src) {
		ArrayList<String> words = tag2List(src);
		return (String[]) words.toArray(new String[words.size()]);
	}
750228
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public TagContext tagContextCreation(Data data) {
    return TagsBenchmarksUtil.createTagContext(data.tagger.emptyBuilder(), data.numTags);
  }
84904
@Override
   public void tag(Annotation sentence) {
      SequenceInput<Annotation> sequenceInput = new SequenceInput<>(sentence.tokens());
      Labeling result = labeler.label(featurizer.extractSequence(sequenceInput.iterator()));
      for (int i = 0; i < sentence.tokenLength(); ) {
         if (result.getLabel(i).equals("O")) {
            i++;
         } else {
            Annotation start = sentence.tokenAt(i);
            String type = result.getLabel(i).substring(2);
            i++;
            while (i < sentence.tokenLength() && result.getLabel(i).startsWith("I-")) {
               i++;
            }
            Annotation end = sentence.tokenAt(i - 1);
            HString span = start.union(end);
            Annotation entity = sentence.document()
                                        .annotationBuilder()
                                        .type(annotationType)
                                        .bounds(span)
                                        .createAttached();
            entity.put(annotationType.getTagAttribute(),
                       annotationType.getTagAttribute().getValueType().decode(type));
         }
      }
   }
837805
public static Set extractStringsInbetweenTagsFromText(String input, char startTag, char endTag, boolean sort) {
		
		TreeMap<String, Object> storage = new TreeMap<String, Object>();
		HashSet<String> unsortedStorage = new HashSet<String>();

		StringBuffer word = new StringBuffer();
		boolean readingWord = false;
		LOOP:
		for (int i = 0; i < input.length(); i++) {
			if (readingWord) {
				if (input.charAt(i) == endTag) {
					//check forbidden word list first
					//or maybe make arrangements in Index
					//e.g.: disable Index with too many (%) references


					String foundWord = word.toString();
					if (!sort) {
						if (!storage.containsKey(foundWord)) {
							unsortedStorage.add(foundWord);
						}
					}


					storage.put(foundWord, new Object());
					readingWord = false;
					continue LOOP;
				}
				else {
					word.append(input.charAt(i));
				}
			}
			else {
				if (input.charAt(i) == startTag) {
					word = new StringBuffer();
					readingWord = true;
				}
				else {
					continue LOOP;
				}
			}
		}
		if (readingWord) {
			String foundWord = word.toString()/*.toLowerCase()*/;
			if (!sort) {
				if (!storage.containsKey(foundWord)) {
					unsortedStorage.add(foundWord);
				}
			}
			storage.put(foundWord, new Object());
		}
		if (sort) {
			return storage.keySet();
		}
		else {
			return unsortedStorage;
		}
	}
1104676
@SuppressWarnings("unchecked")
	public String strLabeling(String data){
		List lblSeqs = seqLabeling(data);
		String ret = dataWriter.writeString(lblSeqs);
		return ret;
	}
731850
public static byte[] decode(String data) {
	// TODO: when we move to Java 8 change to
	// https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Decoder.html
	return org.apache.commons.codec.binary.Base64.decodeBase64(data);
    }
304488
public static String digest(final String alg, final String data) {
        return digest(alg, data.getBytes(StandardCharsets.UTF_8));
    }