public class SimilarityCalculator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected Model |
model
Model of similarity
|
protected int |
nGrams
N value for the n-grams
|
protected Article |
source
Article in source language
|
protected Article |
target
Article in target language
|
protected RepresentationType |
type
Type of text representation
|
| Modifier | Constructor and Description |
|---|---|
protected |
SimilarityCalculator(java.lang.String srcLang,
java.lang.String trgLang,
RepresentationType type,
Model simModel)
Creates a similarity calculator with the given arguments and
n=1
for the n-grams methods. |
|
SimilarityCalculator(java.lang.String srcLang,
java.lang.String trgLang,
RepresentationType type,
Model simModel,
int nGrams)
Creates a similarity calculator with the given arguments.
|
| Modifier and Type | Method and Description |
|---|---|
SimilarityMatrix |
calculate(java.io.File src,
java.io.File trg)
Calculates the matrix of similarities for the given files.
|
protected void |
calculateInvIndex()
Generate the inverted index of the articles
|
protected SimilarityMatrix |
calculateSimilarityMatrix()
Calculates the resulting matrix
|
protected void |
createRepresentations()
Creates the representations of the source text and the target text
|
static SimilarityCalculator |
getInstance(java.lang.String src,
java.lang.String trg,
Similarity method)
Returns the suitable calculator according to the given similarity method.
|
static SimilarityCalculator |
getInstance(java.lang.String src,
java.lang.String trg,
Similarity method,
int nGrams)
Returns the suitable calculator according to the given similarity method.
|
Model |
getModel() |
int |
getnGrams() |
Article |
getSource() |
Article |
getTarget() |
RepresentationType |
getType() |
void |
setModel(Model model) |
void |
setnGrams(int nGrams) |
void |
setSource(Article source) |
void |
setTarget(Article target) |
void |
setType(RepresentationType type) |
protected Article source
protected Article target
protected int nGrams
protected RepresentationType type
protected Model model
protected SimilarityCalculator(java.lang.String srcLang,
java.lang.String trgLang,
RepresentationType type,
Model simModel)
n=1
for the n-grams methods.srcLang - Source languagetrgLang - Target languagetype - Type of representation needed by the calculatorsimModel - Type of similarity model needed by the calculator.public SimilarityCalculator(java.lang.String srcLang,
java.lang.String trgLang,
RepresentationType type,
Model simModel,
int nGrams)
srcLang - Source languagetrgLang - Target languagetype - Type of representation needed by the calculatorsimModel - Type of similarity model needed by the calculator.nGrams - The value of N for the representations which uses n-gramspublic static SimilarityCalculator getInstance(java.lang.String src, java.lang.String trg, Similarity method)
method - The desired method.public static SimilarityCalculator getInstance(java.lang.String src, java.lang.String trg, Similarity method, int nGrams)
nGrams.method - The desired method.nGrams - The value of n for the n-grams, if it's needed.null object is retourned if the method
is unknown.public SimilarityMatrix calculate(java.io.File src, java.io.File trg) throws java.io.IOException
src - File which contains the source articletrg - File which contains the target articlejava.io.IOExceptionprotected void createRepresentations()
src - Source text.trg - Target textprotected void calculateInvIndex()
protected SimilarityMatrix calculateSimilarityMatrix()
null matrix is
retourned if the model is unknownpublic void setSource(Article source)
source - Article of the source languagepublic void setTarget(Article target)
target - Article of the target languagepublic void setnGrams(int nGrams)
nGrams - The N value when a representation uses n-gramspublic void setType(RepresentationType type)
type - The type of representation of the text that can be performed.public void setModel(Model model)
model - The new model of similarity which is able to calculatepublic Article getSource()
public Article getTarget()
public int getnGrams()
public RepresentationType getType()
public Model getModel()