![JAR search and dependency download from the Maven repository](/logo.png)
de.citec.tcs.alignment.sequence.VectorialKeywordSpecification Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sequences Show documentation
Show all versions of sequences Show documentation
This module contains the sequence datastructure of the
TCS Alignment Toolbox. It defines the possible value sets in the
ValueType enum as well as the different KeywordSpecification classes, namely:
1.) StringKeywordSpecification for string type values.
2.) SymbolicKeywordSpecification for values from a discrete alphabet (also refer to the Alphabet class)
3.) VectorialKeywordSpecification for vectors of some length (or for scalars)
A NodeSpecification is a vector of such KeywordSpecifications and defines
the order of value sets. A node, then, is defined as a vector of values
from these value sets (also refer to the Value interface as well as the
StringValue, SymbolicValue and VectorialValue classes). Finally a
sequence is defined as a list of such nodes.
/*
* TCS Alignment Toolbox Version 3
*
* Copyright (C) 2016
* Benjamin Paaßen
* AG Theoretical Computer Science
* Centre of Excellence Cognitive Interaction Technology (CITEC)
* University of Bielefeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package de.citec.tcs.alignment.sequence;
import lombok.NonNull;
/**
* This specifies vectors by their length.
*
* @author Benjamin Paassen - [email protected]
*/
public class VectorialKeywordSpecification extends KeywordSpecification {
private final int length;
public VectorialKeywordSpecification(int length, @NonNull String keyword) {
super(keyword, ValueType.VECTOR);
this.length = length;
}
/**
* The length all vectors for this keyword have to have.
*
* @return The length all vectors for this keyword have to have.
*/
public int getLength() {
return length;
}
/**
* This applies the KeywordSpecification validation and additionally checks
* whether the given value has the correct length.
*
* {@inheritDoc }
*/
@Override
public boolean validate(Value value) {
return value == null
|| (super.validate(value)
&& ((VectorialValue) value).getVector().length == length);
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + super.hashCode();
hash = 59 * hash + this.length;
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final VectorialKeywordSpecification other = (VectorialKeywordSpecification) obj;
if (!super.equals(obj)) {
return false;
}
if (this.length != other.length) {
return false;
}
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy