本文整理匯總了Java中it.uniroma2.sag.kelp.data.representation.Vector類的典型用法代碼示例。如果您正苦於以下問題:Java Vector類的具體用法?Java Vector怎麽用?Java Vector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Vector類屬於it.uniroma2.sag.kelp.data.representation包,在下文中一共展示了Vector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCompositionalInformationFor
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This method takes in input two LexicalStructureElement representing a
* head and a modifier. It returns an Example that contains a
* representation, whose name is <code>VECTOR_NAME</code>, containing the
* pointwise product of the two Vector representations of the head and
* modifier. In case of missing head, the resulting composition is obtained
* by copying the modifier in the head. In case of missing modifier, the
* resulting composition is obtained by copying the head in the modifier. In
* case of missing head and modifier, the method returns null.
*
* @param head
* @param modifier
* @param ws
* the StructureElementSimilarityWordSpace used to retrieve the
* Vector representations of head and modifiers.
*
* @return the compositional Example
*/
public Vector getCompositionalInformationFor(LexicalStructureElement head,
LexicalStructureElement modifier) {
Vector hExample = getWordspace().getVector(head.getTextFromData());
Vector mExample = getWordspace().getVector(modifier.getTextFromData());
if (hExample == null && mExample == null) {
return null;
}
if (hExample == null && mExample != null) {
hExample = mExample;
}
if (mExample == null && hExample != null) {
mExample = hExample;
}
return product(hExample, mExample);
}
示例2: getCompositionalInformationFor
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This method takes in input two LexicalStructureElement representing a
* head and a modifier. It returns an Example that contains a
* representation, whose name is <code>VECTOR_NAME</code>, containing the
* dilation of the two vector representations of the head and modifier. In
* case of missing head, the resulting composition is obtained by copying
* the modifier in the head. In case of missing modifier, the resulting
* composition is obtained by copying the head in the modifier. In case of
* missing head and modifier, the method returns null.
*
* @param head
* @param modifier
* @param ws
* the StructureElementSimilarityWordSpace used to retrieve the
* vector representations of head and modifiers.
*
* @return the compositional Example
*/
public Vector getCompositionalInformationFor(LexicalStructureElement head,
LexicalStructureElement modifier) {
Vector hExample = getWordspace().getVector(head.getTextFromData());
Vector mExample = getWordspace().getVector(modifier.getTextFromData());
if (hExample == null && mExample == null) {
return null;
}
if (hExample == null && mExample != null) {
hExample = mExample;
}
if (mExample == null && hExample != null) {
mExample = hExample;
}
return dilation(hExample, mExample);
}
示例3: dilation
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
private static Vector dilation(Vector hExample, Vector mExample) {
// Compute the head and modifier dilation factors
float hD = hExample.innerProduct(hExample);
float hmD = hExample.innerProduct(mExample);
// Dilate head
Vector headUU = hExample.copyVector();
headUU.scale(hD);
// Dilate modifier
Vector modUV = mExample.copyVector();
modUV.scale(hmD);
// Sum contributions
headUU.add(modUV);
headUU.normalize();
return headUU;
}
示例4: getCompositionalInformationFor
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This method takes in input two LexicalStructureElement representing a
* head and a modifier. It returns an Example that contains a
* representation, whose name is <code>VECTOR_NAME</code>, containing the
* sum of the two Vector representations of the head and modifier. In case
* of missing head, the resulting composition is obtained by copying the
* modifier in the head. In case of missing modifier, the resulting
* composition is obtained by copying the head in the modifier. In case of
* missing head and modifier, the method returns null.
*
* @param head
* @param modifier
* @param ws
* the StructureElementSimilarityWordSpace used to retrieve the
* Vector representations of head and modifiers.
*
* @return the compositional Vector
*/
public Vector getCompositionalInformationFor(LexicalStructureElement head,
LexicalStructureElement modifier) {
Vector hVec = getWordspace().getVector(head.getTextFromData());
Vector mVec = getWordspace().getVector(modifier.getTextFromData());
if (hVec == null && mVec == null) {
return null;
}
if (hVec == null && mVec != null) {
hVec = mVec;
}
if (mVec == null && hVec != null) {
mVec = hVec;
}
return sum(hVec, mVec);
}
示例5: getSimilarity
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* Returns the similarity between <code>vector1</code> and <code>vector2</code>
* computed using the kernel function
*
* @param vector1 the first vector to be compared
* @param vector2 the second vector to be compared
* @return the similarity between <code>vector1</code> and <code>vector2</code>
*/
protected float getSimilarity(Vector vector1, Vector vector2){
if(vector1==null || vector2==null){
return 0;
}
if(kernel==null){
return vector1.innerProduct(vector2);
}
example1.addRepresentation(VECTOR_NAME, vector1);
example2.addRepresentation(VECTOR_NAME, vector2);
return this.kernel.innerProduct(example1, example2);
}
示例6: getScore
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
protected float getScore(CompositionalStructureElement csx,
CompositionalStructureElement csz) {
Vector storedSx = (Vector) csx.getAdditionalInformation(enrichmentName);
if (storedSx == null && csx.containsAdditionalInfo(enrichmentName))
return 0.0f;
Vector storedSz = (Vector) csz.getAdditionalInformation(enrichmentName);
if (storedSz == null && csz.containsAdditionalInfo(enrichmentName))
return 0.0f;
if (storedSx == null) {
storedSx = getCompositionalInformationFor(csx.getHead(),
csx.getModifier());
if (storedSx == null) {
return 0.0f;
}
}
if (storedSz == null) {
storedSz = getCompositionalInformationFor(csz.getHead(),
csz.getModifier());
if (storedSz == null) {
return 0.0f;
}
}
return getSimilarity(storedSx, storedSz);
}
示例7: product
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
private static Vector product(Vector hExample, Vector mExample) {
Vector prod = hExample.copyVector();
prod.pointWiseProduct(mExample);
prod.normalize();
return prod;
}
示例8: enrichTreeWithCompositionalProduct
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This method enriches the CompositionalStructureElement{s} with the
* pointwise product of the vectors of head and modifiers.
*
* @param repr
* the representation to be enriched
*/
private void enrichTreeWithCompositionalProduct(TreeRepresentation repr) {
for (TreeNode node : repr.getAllNodes()) {
if (node.getContent() instanceof CompositionalStructureElement) {
CompositionalStructureElement el = (CompositionalStructureElement) node
.getContent();
Vector compositionalInfo = getCompositionalInformationFor(
el.getHead(), el.getModifier());
el.addAdditionalInformation(enrichmentName, compositionalInfo);
}
}
}
示例9: getScore
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
public float getScore(CompositionalStructureElement csx,
CompositionalStructureElement csz) {
Vector storedSx = (Vector) csx.getAdditionalInformation(enrichmentName);
if (storedSx == null && csx.containsAdditionalInfo(enrichmentName))
return 0.0f;
Vector storedSz = (Vector) csz.getAdditionalInformation(enrichmentName);
if (storedSz == null && csz.containsAdditionalInfo(enrichmentName))
return 0.0f;
if (storedSx == null) {
storedSx = getCompositionalInformationFor(csx.getHead(),
csx.getModifier());
if (storedSx == null) {
return 0.0f;
}
}
if (storedSz == null) {
storedSz = getCompositionalInformationFor(csz.getHead(),
csz.getModifier());
if (storedSz == null) {
return 0.0f;
}
}
return getSimilarity(storedSx, storedSz);
}
示例10: enrichTreeWithCompositionalDilation
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This method enriches the CompositionalStructureElement{s} applying the
* dilation to head and modifiers vectors.
*
* @param repr
* the representation to be enriched
*/
private void enrichTreeWithCompositionalDilation(TreeRepresentation repr) {
for (TreeNode node : repr.getAllNodes()) {
if (node.getContent() instanceof CompositionalStructureElement) {
CompositionalStructureElement el = (CompositionalStructureElement) node
.getContent();
Vector compositionalInfo = getCompositionalInformationFor(el.getHead(),
el.getModifier());
el.addAdditionalInformation(enrichmentName,
compositionalInfo);
}
}
}
示例11: enrichTreeWithCompositionalSum
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This method enriches the CompositionalStructureElement{s} with the sum of
* the vectors of head and modifiers.
*
* @param repr
* the representation to be enriched
*/
private void enrichTreeWithCompositionalSum(TreeRepresentation repr) {
for (TreeNode node : repr.getAllNodes()) {
if (node.getContent() instanceof CompositionalStructureElement) {
CompositionalStructureElement el = (CompositionalStructureElement) node
.getContent();
Vector compositionalInfo = getCompositionalInformationFor(
el.getHead(), el.getModifier());
el.addAdditionalInformation(enrichmentName, compositionalInfo);
}
}
}
示例12: enrichTreeRepresentation
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This function enriches each <code>LexicalStructureElement</code> in the
* tree with a vector from the Word Space
*
* @param treeRepresentation
* The tree to be enriched
*/
public static void enrichTreeRepresentation(TreeRepresentation treeRepresentation,
WordspaceI wordSpace, String enrichmentName) {
for (TreeNode treeNode : treeRepresentation.getAllNodes()) {
StructureElement content = treeNode.getContent();
if (content instanceof LexicalStructureElement) {
Vector vector = wordSpace.getVector(content.getTextFromData());
content.addAdditionalInformation(enrichmentName, vector);
}
}
}
示例13: getContentSimilarity
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
private float getContentSimilarity(StructureElement element1, StructureElement element2){
String text1 = element1.getTextFromData();
String text2 = element2.getTextFromData();
/*
* If both elements have the same type, if they have the same label, the
* similarity is 1. It is true for SYNT and POS elements
*/
if(text1.equals(text2)){
return 1;
}
if(element1 instanceof LexicalStructureElement ){
LexicalStructureElement lex1 = (LexicalStructureElement) element1;
LexicalStructureElement lex2 = (LexicalStructureElement) element2;
if(ignorePosInLemmaMatches){
if(lex1.getLemma().equals(lex2.getLemma())){
return 1;
}
}
if(!allowDifferentPOS){
String pos1 = lex1.getPos();
String pos2 = lex2.getPos();
if(!pos1.equals(pos2)){
return 0;
}
}
Vector vect1 = this.getCorrespondingVector(element1);
Vector vect2 = this.getCorrespondingVector(element2);
float sim = this.getSimilarity(vect1, vect2);
if(sim>0){
return sim;
}
}
return 0;
}
示例14: getCorrespondingVector
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* Returns the vector associated to <code>element</code>. It firstly tries to
* check whether a vector as been attached as additional information to <code>element</code>.
* If no vector has been attached it retrieves the vector associated to the textual representation
* of <code>element</code> (applying <code>element.getTextFromData()</code>) in the wordspace.
*
*
* @param element the structure element whose corresponding vector must be retrieved
* @return the vector associated to <code>element</code>
*/
protected Vector getCorrespondingVector(StructureElement element){
if(element.containsAdditionalInfo(enrichmentName)){
return (Vector) element.getAdditionalInformation(enrichmentName);
}else{
return this.wordspace.getVector(element.getTextFromData());
}
}
示例15: getCompositionalInformationFor
import it.uniroma2.sag.kelp.data.representation.Vector; //導入依賴的package包/類
/**
* This method takes in input two LexicalStructureElement representing a
* head and a modifier. It returns an Example that contains a
* representation, whose name is <code>VECTOR_NAME</code>, containing the
* sum of the two vector representations of the head and modifier. In case
* of missing head, the resulting composition is obtained by copying the
* modifier in the head. In case of missing modifier, the resulting
* composition is obtained by copying the head in the modifier. In case of
* missing head and modifier, the method returns null.
*
* @param head
* @param modifier
* @param ws
* the StructureElementSimilarityWordSpace used to retrieve the
* vector representations of head and modifiers.
*
* @return the compositional Vector
*/
public abstract Vector getCompositionalInformationFor(
LexicalStructureElement head, LexicalStructureElement modifier);