public class VectorMap
extends java.util.HashMap<java.lang.String,float[]>
Constructor and Description |
---|
VectorMap()
Create an empty word vector storage.
|
VectorMap(java.util.Map<java.lang.String,float[]> vectors)
Initialize word vectors from a given map.
|
Modifier and Type | Method and Description |
---|---|
static VectorMap |
deserialize(java.io.InputStream in)
Read word vectors from an input stream.
|
static VectorMap |
deserialize(java.lang.String file)
Read word vectors from a file or classpath or url.
|
boolean |
equals(java.lang.Object other) |
int |
hashCode() |
static VectorMap |
readWord2Vec(java.lang.String file)
Read the Word2Vec word vector flat txt file.
|
void |
serialize(java.io.OutputStream out)
Write the word vectors to an output stream.
|
void |
serialize(java.lang.String file)
Write the word vectors to a file.
|
java.lang.String |
toString() |
public VectorMap()
public VectorMap(java.util.Map<java.lang.String,float[]> vectors)
vectors
- The word vectors as a simple map.public void serialize(java.lang.String file) throws java.io.IOException
file
- The file to write to.java.io.IOException
- Thrown if the file could not be written to.public void serialize(java.io.OutputStream out) throws java.io.IOException
out
- The stream to write to.java.io.IOException
- Thrown if the stream could not be written to.public static VectorMap deserialize(java.lang.String file) throws java.io.IOException
file
- The file to read from.java.io.IOException
- Thrown if we could not read from the resourcepublic static VectorMap deserialize(java.io.InputStream in) throws java.io.IOException
in
- The stream to read from. This is not closed.java.io.IOException
- Thrown if we could not read from the stream.public static VectorMap readWord2Vec(java.lang.String file)
file
- The word2vec text file.public boolean equals(java.lang.Object other)
equals
in interface java.util.Map<java.lang.String,float[]>
equals
in class java.util.AbstractMap<java.lang.String,float[]>
public int hashCode()
hashCode
in interface java.util.Map<java.lang.String,float[]>
hashCode
in class java.util.AbstractMap<java.lang.String,float[]>
public java.lang.String toString()
toString
in class java.util.AbstractMap<java.lang.String,float[]>