从bin加载
@param byteArray
@return
548890
public boolean load(ByteArray byteArray)
    {
        if (byteArray == null) return false;
        model_header = byteArray.nextString();
        root = byteArray.nextString();

        use_distance = byteArray.nextInt() == 1;
        use_valency = byteArray.nextInt() == 1;
        use_cluster = byteArray.nextInt() == 1;

        W1 = new Matrix();
        W1.load(byteArray);
        W2 = new Matrix();
        W2.load(byteArray);
        E = new Matrix();
        E .load(byteArray);
        b1 = new Matrix();
        b1 .load(byteArray);
        saved = new Matrix();
        saved .load(byteArray);

        forms_alphabet = new Alphabet();
        forms_alphabet .load(byteArray);
        postags_alphabet = new Alphabet();
        postags_alphabet .load(byteArray);
        deprels_alphabet = new Alphabet();
        deprels_alphabet .load(byteArray);

        precomputation_id_encoder = read_map(byteArray);

        if (use_cluster)
        {
            cluster4_types_alphabet = new Alphabet();
            cluster4_types_alphabet.load(byteArray);
            cluster6_types_alphabet = new Alphabet();
            cluster6_types_alphabet .load(byteArray);
            cluster_types_alphabet = new Alphabet();
            cluster_types_alphabet .load(byteArray);

            form_to_cluster4 = read_map(byteArray);
            form_to_cluster6 = read_map(byteArray);
            form_to_cluster = read_map(byteArray);
        }

        assert !byteArray.hasMore() : "文件有残留，可能是读取逻辑不对";

        classifier = new NeuralNetworkClassifier(W1, W2, E, b1, saved, precomputation_id_encoder);
        classifier.canonical();

        return true;
    }
50890
public static MaxEntModel create(ByteArray byteArray)
    {
        MaxEntModel m = new MaxEntModel();
        m.correctionConstant = byteArray.nextInt();  // correctionConstant
        m.correctionParam = byteArray.nextDouble();  // getCorrectionParameter
        // label
        int numOutcomes = byteArray.nextInt();
        String[] outcomeLabels = new String[numOutcomes];
        m.outcomeNames = outcomeLabels;
        for (int i = 0; i < numOutcomes; i++) outcomeLabels[i] = byteArray.nextString();
        // pattern
        int numOCTypes = byteArray.nextInt();
        int[][] outcomePatterns = new int[numOCTypes][];
        for (int i = 0; i < numOCTypes; i++)
        {
            int length = byteArray.nextInt();
            int[] infoInts = new int[length];
            for (int j = 0; j < length; j++)
            {
                infoInts[j] = byteArray.nextInt();
            }
            outcomePatterns[i] = infoInts;
        }
        // feature
        int NUM_PREDS = byteArray.nextInt();
        String[] predLabels = new String[NUM_PREDS];
        m.pmap = new DoubleArrayTrie<Integer>();
        for (int i = 0; i < NUM_PREDS; i++)
        {
            predLabels[i] = byteArray.nextString();
        }
        Integer[] v = new Integer[NUM_PREDS];
        for (int i = 0; i < v.length; i++)
        {
            v[i] = byteArray.nextInt();
        }
        m.pmap.load(byteArray, v);
        // params
        Context[] params = new Context[NUM_PREDS];
        int pid = 0;
        for (int i = 0; i < outcomePatterns.length; i++)
        {
            int[] outcomePattern = new int[outcomePatterns[i].length - 1];
            for (int k = 1; k < outcomePatterns[i].length; k++)
            {
                outcomePattern[k - 1] = outcomePatterns[i][k];
            }
            for (int j = 0; j < outcomePatterns[i][0]; j++)
            {
                double[] contextParameters = new double[outcomePatterns[i].length - 1];
                for (int k = 1; k < outcomePatterns[i].length; k++)
                {
                    contextParameters[k - 1] = byteArray.nextDouble();
                }
                params[pid] = new Context(outcomePattern, contextParameters);
                pid++;
            }
        }
        // prior
        m.prior = new UniformPrior();
        m.prior.setLabels(outcomeLabels);
        // eval
        m.evalParams = new EvalParameters(params, m.correctionParam, m.correctionConstant, outcomeLabels.length);
        return m;
    }
797667
public static Guid fromByteArrays(byte[]... byteArrays) throws IOException {
    if (byteArrays == null || byteArrays.length == 0) {
      throw new IOException("Attempting to compute guid for an empty array.");
    }

    if (byteArrays.length == 1) {
      return new Guid(byteArrays[0]);
    }
    byte[] tmp = new byte[0];
    for (byte[] arr : byteArrays) {
      tmp = ArrayUtils.addAll(tmp, arr);
    }
    return new Guid(tmp);
  }
446478
public static String byteArrayAsString(final Object bytearray) throws ParseException
    {
        try
        {
            return new String((byte[]) bytearray, "ISO-8859-1");

        } catch (final UnsupportedEncodingException e)
        {
            throw new ParseException("Literal required, " + e.getMessage(), 0);
        }

    }
1272528
public static String encodeByteArray(byte[] byteArray) {
		try {
			return new String(Base64.encodeBase64(byteArray), UTF8_ENCODING);
		} catch(UnsupportedEncodingException e) {
			throw new MappingException("Could not encode byteArray to UTF8 encoding", e);
		}
	}
1208010
public static void shuffle(byte[] byteArray) {
		int swapPlace = -1;

		for(int i = 0; i < byteArray.length; i++) {
			swapPlace = (int) (Math.random() * (byteArray.length - 1 ));
			XORSwap.swap(byteArray, i, swapPlace);
		}
	}
182057
private static String byteArrayToHexString(byte[] byteArray) {
		StringBuilder result = new StringBuilder();
		
		for (byte b : byteArray) {
			result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
		}
		
		return result.toString();
	}
678734
public static byte[] copy(byte[] array) {
		byte[] newArray = new byte[array.length];
		System.arraycopy(array, 0, newArray, 0, array.length);
		return newArray;
	}
531810
public static int[] binaryToRgb(boolean[] binaryArray) {
        int[] rgbArray = new int[binaryArray.length];

        for (int i = 0; i < binaryArray.length; i++) {
            if (binaryArray[i]) {
                rgbArray[i] = 0x00000000;
            } else {
                rgbArray[i] = 0x00FFFFFF;
            }
        }
        return rgbArray;
    }
1354604
public ByteArrayQueue add(byte[] b, int off, int len) {
		int newLength = addLength(len);
		System.arraycopy(b, off, array, offset + length, len);
		length = newLength;
		return this;
	}
412696
public static BasicVector fromBinary(byte[] array) {
        ByteBuffer buffer = ByteBuffer.wrap(array);

        if (buffer.get() != VECTOR_TAG) {
            throw new IllegalArgumentException("Can not decode BasicVector from the given byte array.");
        }

        double[] values = new double[buffer.getInt()];
        for (int i = 0; i < values.length; i++) {
            values[i] = buffer.getDouble();
        }

        return new BasicVector(values);
    }
1291047
public static Value bytesArray(@Nullable Iterable<ByteArray> v) {
    return new BytesArrayImpl(v == null, v == null ? null : immutableCopyOf(v));
  }
805088
@Override
    public ByteArray readByteArray() {
        int type = readInteger();
        if ((type & 1) == 0) {
            return (ByteArray) getReference(type >> 1);
        }
        type >>= 1;
        ByteArray result = new ByteArray(buf, type);
        storeReference(result);
        return result;
    }
840063
public static String byteArrayToHexString(byte[] b) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < b.length; i++) {
			sb.append(byteToHexString(b[i]));
		}
		return new String(sb);
	}
225645
public static byte[] toByteArray(InputStream in) throws IOException {
    checkNotNull(in, "in");
    try {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      copy(in, out);
      return out.toByteArray();
    } finally {
      ensureClosed(in);
    }
  }
99851
public byte[] toByteArray() {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(this);
            return baos.toByteArray();
        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
194447
private static String byteToStr(byte[] byteArray) {
        int len = byteArray.length;
        StringBuilder strDigest = new StringBuilder(len * 2);
        for (byte aByteArray : byteArray) {
            strDigest.append(byteToHexStr(aByteArray));
        }
        return strDigest.toString();
    }