Loads the {@link SemanticSpace} from the binary formatted file, adding
its words to {@link #termToIndex} and returning the {@code Matrix}
containing the space's vectors.

@param sspaceFile a file in {@link SSpaceFormat#BINARY binary} format
196723
private Matrix loadBinary(InputStream fileStream) throws IOException {
        DataInputStream dis = new DataInputStream(fileStream);
        int rows = dis.readInt();
        int cols = dis.readInt();

        // create a dense matrix
        Matrix m = new ArrayMatrix(rows, cols);
        double[] d = new double[cols];
        for (int row = 0; row < rows; ++row) {
            String word = dis.readUTF();
            termToIndex.put(word, row);

            for (int col = 0; col < cols; ++col) {
                d[col] = dis.readDouble();
            }
            m.setRow(row, d);
        }
        return m;
    }
942870
public static SimpleMatrix loadBinary( String fileName )
            throws IOException {
        DMatrix mat = MatrixIO.loadBin(fileName);

        // see if its a DMatrixRMaj
        if( mat instanceof DMatrixRMaj) {
            return SimpleMatrix.wrap((DMatrixRMaj)mat);
        } else {
            // if not convert it into one and wrap it
            return SimpleMatrix.wrap( new DMatrixRMaj(mat));
        }
    }
665510
public Hashtable<String,List<Other>> attributesWithNamespace(String namespace) {


        Hashtable<String,List<Other>> result=namespaceIndex.get(namespace);
        if (result==null) {
            result=new Hashtable<String,List<Other>>();
            namespaceIndex.put(namespace,result);
        }

        for (Other attribute: attributes) {
            
            QualifiedName name=attribute.getElementName();
            if (namespace.equals(name.getNamespaceURI())) {
                List<Other> ll=result.get(name.getLocalPart());
                if (ll==null) {
                    List<Other> tmp=new LinkedList<Other>();
                    tmp.add(attribute);
                    result.put(name.getLocalPart(),tmp);
                } else {
                    ll.add(attribute);                        
                }
            }
        }
        return result;
    }
1142170
public final void nameSpace (String namespace) {
    if (namespace == null || namespace.equals("")) {
      _namespace = "";
    } else {
      _namespace = namespace + ":";
    }
  }
97102
private static Matrix readMatlabSparse(
             File matrixFile,
             Type matrixType,
             boolean transposeOnRead) throws IOException {

         Matrix matrix = new GrowingSparseMatrix();
         BufferedReader br = new BufferedReader(new FileReader(matrixFile));
         for (String line = null; (line = br.readLine()) != null; ) {
             String[] rowColVal = line.split("\\s+");
             int row = Integer.parseInt(rowColVal[0]) - 1;
             int col = Integer.parseInt(rowColVal[1]) - 1;
             double value = Double.parseDouble(rowColVal[2]);
             if (transposeOnRead)
                 matrix.set(col, row, value);
             else
                 matrix.set(row, col, value);
         }
         br.close();
         return matrix;
     }
903428
private static void addCodeToProvideSoyNamespace(StringBuilder header, SoyFileNode soyFile) {
    header.append("goog.provide('").append(soyFile.getNamespace()).append("');\n");
  }
252283
def ensure_regex_namespace(self, keyword: str, pattern: str) -> Namespace:
        
        if pattern is None:
            raise ValueError('cannot have null pattern')

        namespace = self.get_namespace_by_keyword_pattern(keyword, pattern)

        if namespace is None:
            log.info('creating regex namespace: %s:%s', keyword, pattern)
            namespace = Namespace(
                keyword=keyword,
                pattern=pattern
            )
            self.session.add(namespace)
            self.session.commit()

        return namespace
598006
public static void printTemporalSemanticSpace(TemporalSemanticSpace sspace,
                                                  File output, 
                                                  TSSpaceFormat format) 
        throws IOException {

        switch (format) {
        case TEXT:
            printText(sspace, output);
            break;
        case SPARSE_TEXT:
            printSparseText(sspace, output);
            break;
        case BINARY:
            printBinary(sspace, output);
            break;
        case SPARSE_BINARY:
            printSparseBinary(sspace, output);
            break;
        default:
            throw new IllegalArgumentException("Unknown format type: "+ format);
        }
    }
48837
public static Scs cs_load(String fileName) {
        int i, j;
        float x;
        Scs T;
        BufferedReader in;
        try {
            in = new BufferedReader(new FileReader(fileName));
        } catch (FileNotFoundException e1) {
            return (null);
        }
        T = Scs_util.cs_spalloc(0, 0, 1, true, true); /* allocate result */
        String line;
        try {
            while ((line = in.readLine()) != null) {
                String[] tokens = line.trim().split("\\s+");
                if (tokens.length != 3) {
                    return null;
                }
                i = Integer.parseInt(tokens[0]);
                j = Integer.parseInt(tokens[1]);
                x = Float.parseFloat(tokens[2]);
                if (!Scs_entry.cs_entry(T, i, j, x))
                    return (null);
            }
        } catch (IOException e) {
            return (null);
        }
        return (T);
    }
130215
public void useNamespace(SerializerContext serializerContext, ElementDescriptor<?> elementDescriptor)
	{
		useNamespace(serializerContext, elementDescriptor.qualifiedName.namespace);
	}
188662
public static void binaryToText(String featuresFolder, final String featureType, int featureLength)
			throws Exception {
		// read the folder containing the description files
		File dir = new File(featuresFolder);
		FilenameFilter filter = new FilenameFilter() {
			public boolean accept(File dir, String name) {
				if (name.endsWith("." + featureType + "b"))
					return true;
				else
					return false;
			}
		};
		String[] files = dir.list(filter);

		for (int i = 0; i < files.length; i++) {
			if (i % 100 == 0) {
				System.out.println("Converting file " + i);
			}

			DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(
					featuresFolder + files[i])));
			BufferedWriter out = new BufferedWriter(new FileWriter(new File(featuresFolder
					+ files[i].replace("b", ""))));
			long counter = 0;
			while (true) {
				try {
					double val = in.readDouble();
					out.write(String.valueOf(val));
				} catch (EOFException e) {
					break;
				}
				counter++;
				if (counter % featureLength == 0) {
					out.write("\n");
				} else {
					out.write(",");
				}

			}
			in.close();
			out.close();
		}
	}
836954
public void load(String modelFile) throws IOException, ClassNotFoundException {
		System.out.println("加载N-Gram模型:" + modelFile);
		System.out.println("load ...");
		System.out.println(modelFile);
		ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(
				new GZIPInputStream(new FileInputStream(modelFile))));
		n = (Integer) in.readObject(); 
		System.out.println("ngram " + n);
		in.close();
		System.out.println("load end");
	}
468036
@Override
    public Namespace createNamespace(Namespace namespace) {
        requireNotDisposed();
        requireArgument(namespace != null, "null namespace cannot be created.");
        
        if (!_validateQualifier(namespace.getQualifier())) {
            throw new SystemException(new IllegalArgumentException(
                    "Illegal characters found while generating namespace. Cannot generate a namespace with this qualifier."));
        }
        
        if (Namespace.findByQualifier(emf.get(), namespace.getQualifier()) != null) {
            throw new SystemException(new IllegalArgumentException("Namespace already exists. Please try a different namespace."));
        }
        
        namespace = updateNamespace(namespace);
        _logger.debug("Generated namespace {}.", namespace);
        return namespace;
    }
85542
public String getNameSpace() {
        if (nameSpace == null) {
            nameSpace = new StringBuilder().append(catalog).append(".").append(table).toString();
        }
        return nameSpace;

    }
1268164
private Matrix loadText(InputStream fileStream) throws IOException {
        Matrix matrix = null;

        BufferedReader br = 
                new BufferedReader(new InputStreamReader(fileStream));
        String line = br.readLine();
        if (line == null)
            throw new IOException("Empty .sspace file");
            // Strip off the 4-byte (2 char) header
        String[] dimensions = line.split("\\s");
        int rows = Integer.parseInt(dimensions[0]);
        int columns = Integer.parseInt(dimensions[1]);
        int index = 0;
        
        // reusable array for writing rows into the matrix
        double[] row = new double[columns];
        
        matrix = new ArrayMatrix(rows, columns);

        while ((line = br.readLine()) != null) {
            if (index >= rows)
                throw new IOException("More rows than specified");
            String[] termVectorPair = line.split("\\|");
            String[] values = termVectorPair[1].split("\\s");
            termToIndex.put(termVectorPair[0], index);
            if (values.length != columns) {
                throw new IOException(
                            "improperly formated semantic space file");
            }
            for (int c = 0; c < columns; ++c) {
                double d = Double.parseDouble(values[c]);
                row[c] = d;
                // matrix.set(index, c, d);
            }
            matrix.setRow(index, row);
            index++;
        }
        if (index != rows)
            throw new IOException(String.format(
                "Expected %d rows; saw %d", rows, index));
        return matrix;    
    }
246653
@Override
    public void setTopicSpace(String tSpace) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setTopicSpace", tSpace);
        setDestName(tSpace);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setTopicSpace");
    }
318570
public boolean loadDictionary(InputStream corpus, int termIndex, int countIndex) {
    if (corpus == null) {
      return false;
    }
    BufferedReader br = new BufferedReader(new InputStreamReader(corpus, StandardCharsets.UTF_8));
    return loadDictionary(br, termIndex, countIndex);
  }