All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.amygdalum.util.text.QGramAlphabet Maven / Gradle / Ivy

The newest version!
package net.amygdalum.util.text;

import java.util.List;

public class QGramAlphabet {

	private QGramMapping mapping;
	private int minQGram;
	private int maxQGram;

	private QGramAlphabet(QGramMapping mapping) {
		this.mapping = mapping;
		this.minQGram = Integer.MAX_VALUE;
		this.maxQGram = 0;
	}

	public static QGramAlphabet of(List patterns, QGramMapping mapping) {
		QGramAlphabet qgramAlphabet = new QGramAlphabet(mapping);
		for (char[] pattern : patterns) {
			for (int qc : mapping.iterate(pattern)) {
				qgramAlphabet.add(qc);
			}
		}
		return qgramAlphabet;
	}
	
	public QGramMapping getMapping() {
		return mapping;
	}

	public void add(int qc) {
		if (qc < minQGram) {
			minQGram = qc;
		}
		if (qc > maxQGram) {
			maxQGram = qc;
		}
	}

	public int minQGram() {
		return minQGram;
	}

	public int maxQGram() {
		return maxQGram;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy