Commit 3250467b authored by Sylvain Meignier's avatar Sylvain Meignier
Browse files

Initial commit

parents
Pipeline #567 canceled with stages
/**
*
* <p>
* FSMSausageNode
* </p>
*
* @author <a href="mailto:sylvain.meignier@lium.univ-lemans.fr">Sylvain Meignier</a>
* @version v2.0
*
* Copyright (c) 2007-2009 Universite du Maine. All Rights Reserved. Use is subject to license terms.
*
* THIS SOFTWARE IS PROVIDED BY THE "UNIVERSITE DU MAINE" AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package fr.lium.deprecated.spkDiarization;
import fr.lium.experimental.spkDiarization.libClusteringData.transcription.Entity;
// TODO: Auto-generated Javadoc
/**
* The Class FSMSausageNode.
*
* @deprecated
*/
@Deprecated
public class FSMSausageNode {
/** The word. */
private String word;
/** The type. */
private String type;
/** The entity. */
private Entity entity;
/** The probability. */
private double probability;
/** The id. */
protected int id;
/**
* Instantiates a new fSM sausage node.
*
* @param id the id
* @param word the word
* @param probability the probability
* @param type the type
*/
public FSMSausageNode(int id, String word, double probability, String type) {
this.word = word;
this.probability = probability;
this.type = type;
this.id = id;
entity = null;
}
/**
* Debug.
*/
public void debug() {
System.err.print("\t\t<word propability=\"" + probability + "\" word=\"" + word + "\" type=\"" + type);
if (entity != null) {
System.err.print(" entity=\"" + entity.getType() + "\"");
}
System.err.println("/> ");
}
/**
* Gets the word.
*
* @return the word
*/
public String getWord() {
return word;
}
/**
* Gets the type.
*
* @return the type
*/
public String getType() {
return type;
}
/**
* Gets the probability.
*
* @return the probability
*/
public double getProbability() {
return probability;
}
/**
* Gets the id entity.
*
* @return the id entity
*/
public Entity getIdEntity() {
return entity;
}
/**
* Sets the id entity.
*
* @param entity the new id entity
*/
public void setIdEntity(Entity entity) {
this.entity = entity;
}
/**
* Sets the word.
*
* @param word the new word
*/
protected void setWord(String word) {
this.word = word;
}
/**
* Sets the type.
*
* @param type the new type
*/
protected void setType(String type) {
this.type = type;
}
/**
* Sets the probability.
*
* @param probability the new probability
*/
protected void setProbability(double probability) {
this.probability = probability;
}
/**
* Gets the id.
*
* @return the id
*/
public int getId() {
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
protected void setId(int id) {
this.id = id;
}
/**
* Put entity in word.
*/
public void putEntityInWord() {
if (getIdEntity() != null) {
word = entity.getType();
}
}
}
/**
*
* <p>
* Pair
* </p>
*
* @author <a href="mailto:sylvain.meignier@lium.univ-lemans.fr">Sylvain Meignier</a>
* @version v2.0
*
* Copyright (c) 2007-2009 Universite du Maine. All Rights Reserved. Use is subject to license terms.
*
* THIS SOFTWARE IS PROVIDED BY THE "UNIVERSITE DU MAINE" AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. A path that determine an entity in a LinkSet. This class is employed in conjunction of Entity, EntitySet, Link and LinkSet.
*
*/
package fr.lium.deprecated.spkDiarization;
/**
* The Class Pair.
*
* @param <A> the generic type
* @param <B> the generic type
* @deprecated
*/
@Deprecated
public class Pair<A, B> {
/** The fst. */
public A fst;
/** The snd. */
public B snd;
/**
* Instantiates a new pair.
*
* @param a the a
* @param b the b
*/
public Pair(A a, B b) {
fst = a;
snd = b;
}
}
/**
*
* <p>
* ParameterNamedSpeaker
* </p>
*
* @author <a href="mailto:sylvain.meignier@lium.univ-lemans.fr">Sylvain Meignier</a>
* @author <a href="mailto:vincent.jousse@lium.univ-lemans.fr">Vincent Jousse</a>
* @version v2.0
*
* Copyright (c) 2007-2009 Universite du Maine. All Rights Reserved. Use is subject to license terms.
*
* THIS SOFTWARE IS PROVIDED BY THE "UNIVERSITE DU MAINE" AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package fr.lium.deprecated.spkDiarization;
import fr.lium.spkDiarization.parameter.Parameter;
import fr.lium.spkDiarization.parameter.ParameterBase;
/**
* The Class ParameterNamedSpeaker.
*
* @deprecated
*/
@Deprecated
public class ParameterNamedSpeaker extends ParameterBase {
/** The threshold. */
private double threshold;
/** The firstname list. */
private String firstnameList;
/** The word dictonary mask. */
private String wordDictonaryMask;
/** The SCT mask. */
private String SCTMask;
/** The target list. */
private String targetList;
/** The remove check gender. */
private boolean removeCheckGender;
/**
* Instantiates a new parameter named speaker.
*
* @param parameter the parameter
*/
public ParameterNamedSpeaker(Parameter parameter) {
super(parameter);
setThreshold(0.0);
setFirstnameList("%s.lst");
setWordDictonaryMask("%s.dic");
setSCTMask("%s.tree");
setTargetList("%s");
removeCheckGender = false;
}
/*
* @Override public boolean readParameter(int option, String optarg) { if (option == ReferenceThreshold) { setThreshold(Double.parseDouble(optarg)); return true; } else if (option == ReferenceFirstnameList) { setFirstnameList(optarg); return true; }
* else if (option == ReferenceSCTMask) { setSCTMask(optarg); return true; } else if (option == ReferenceWordDictonaryMask) { setWordDictonaryMask(optarg); return true; } else if (option == ReferenceTargetList) { setTargetList(optarg); return true; }
* return false; }
* @Override public void addOptions(ArrayList<LongOptWithAction> list) { list.add(new LongOptWithAction("nThr", 1, null, ReferenceThreshold, null)); list.add(new LongOptWithAction("nFirstNameList", 1, null, ReferenceFirstnameList, null));
* list.add(new LongOptWithAction("nSCTMask", 1, null, ReferenceSCTMask, null)); list.add(new LongOptWithAction("nTargetList", 1, null, ReferenceTargetList, null)); list.add(new LongOptWithAction("nRemoveCheckGender", 0, null,
* ReferenceRemoveCheckGender, null)); }
*/
/**
* Gets the threshold.
*
* @return the threshold
*/
public double getThreshold() {
return threshold;
}
/**
* Sets the threshold.
*
* @param namedNEThr the new threshold
*/
public void setThreshold(double namedNEThr) {
threshold = namedNEThr;
}
/**
* Gets the firstname list.
*
* @return the firstname list
*/
public String getFirstnameList() {
return firstnameList;
}
/**
* Sets the firstname list.
*
* @param firstnameList the new firstname list
*/
public void setFirstnameList(String firstnameList) {
this.firstnameList = firstnameList;
}
/**
* Gets the word dictonary mask.
*
* @return the word dictonary mask
*/
public String getWordDictonaryMask() {
return wordDictonaryMask;
}
/**
* Sets the word dictonary mask.
*
* @param wordDictonaryMask the new word dictonary mask
*/
public void setWordDictonaryMask(String wordDictonaryMask) {
this.wordDictonaryMask = wordDictonaryMask;
}
/**
* Gets the sCT mask.
*
* @return the sCT mask
*/
public String getSCTMask() {
return SCTMask;
}
/**
* Sets the sCT mask.
*
* @param mask the new sCT mask
*/
public void setSCTMask(String mask) {
SCTMask = mask;
}
/**
* Gets the target list.
*
* @return the target list
*/
public String getTargetList() {
return targetList;
}
/**
* Sets the target list.
*
* @param targetList the new target list
*/
public void setTargetList(String targetList) {
this.targetList = targetList;
}
/**
* Gets the removes the check gender.
*
* @return the removes the check gender
*/
public boolean getRemoveCheckGender() {
return removeCheckGender;
}
/**
* Sets the removes the check gender.
*
* @param removeCheckGender the new removes the check gender
*/
public void setRemoveCheckGender(boolean removeCheckGender) {
this.removeCheckGender = removeCheckGender;
}
/**
* Prints the threshold.
*/
public void printThreshold() {
System.out.print("info[ParameterNamedSpeaker] \t --nThr \t named speaker threshold = ");
System.out.println(getThreshold());
}
/**
* Prints the firstname list.
*/
public void printFirstnameList() {
System.out.print("info[ParameterNamedSpeaker] \t --nFirstnameList \t list of firstname with gender information = ");
System.out.println(getFirstnameList());
}
/**
* Prints the word dictonary mask.
*/
public void printWordDictonaryMask() {
System.out.print("info[ParameterNamedSpeaker] \t --nWordDictonaryMask \t dictonary, decoding word list ");
System.out.println(getWordDictonaryMask());
}
/**
* Prints the sct mask.
*/
public void printSCTMask() {
System.out.print("info[ParameterNamedSpeaker] \t --nSCTMask \t Semantic Classification Tree Mask ");
System.out.println(getSCTMask());
}
/**
* Prints the target list.
*/
public void printTargetList() {
System.out.print("info[ParameterNamedSpeaker] \t --nTargetList \t list of target speakers to identify = ");
System.out.println(getTargetList());
}
/**
* Prints the remove check gender.
*/
public void printRemoveCheckGender() {
System.out.print("info[ParameterNamedSpeaker] \t --nRemoveCheckGender \t remove the gender check = ");
System.out.println(getTargetList());
}
}
\ No newline at end of file
This diff is collapsed.
/**
*
* <p>
* WordDictonary
* </p>
*
* @author <a href="mailto:sylvain.meignier@lium.univ-lemans.fr">Sylvain Meignier</a>
* @author <a href="mailto:vincent.jousse@lium.univ-lemans.fr">Vincent Jousse</a>
* @version v2.0
*
* Copyright (c) 2007-2009 Universite du Maine. All Rights Reserved. Use is subject to license terms.
*
* THIS SOFTWARE IS PROVIDED BY THE "UNIVERSITE DU MAINE" AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* not more use
*/
package fr.lium.deprecated.spkDiarization;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.TreeMap;
import fr.lium.spkDiarization.lib.IOFile;
/**
* The Class WordDictonary.
*
* @deprecated
*/
@Deprecated
public class WordDictonary {
/** The number of elements. */
protected int numberOfElements;
/** The str to int. */
protected TreeMap<String, Integer> strToInt;
/** The int to str. */
protected TreeMap<Integer, String> intToStr;
/** The Constant Unknown. */
public static final String Unknown = "UNK";
/**
* Instantiates a new word dictonary.
*/
public WordDictonary() {
strToInt = new TreeMap<String, Integer>();
intToStr = new TreeMap<Integer, String>();
numberOfElements = 0;
}
/**
* Adds the.
*
* @param key the key
*/
public void add(String key) {
strToInt.put(key, numberOfElements);
intToStr.put(numberOfElements, key);
if (numberOfElements < 40) {
System.out.println(numberOfElements + " - " + key);
}
numberOfElements++;
}
/**
* Gets the index.
*
* @param key the key
* @return the index
*/
public int getIndex(String key) {
Integer idx = strToInt.get(key);
if (idx == null) {
return -1;
}
return idx;
}
/**
* Gets the label.
*
* @param key the key
* @return the label
*/
public String getLabel(int key) {
String word = intToStr.get(key);
if (word == null) {
return Unknown;
}
return word;
}
/**
* Read.
*
* @param name the name
* @param mask the mask
* @throws IOException Signals that an I/O exception has occurred.
*/
public void read(String name, String mask) throws IOException {
String filename = IOFile.getFilename(mask, name);
System.out.println("## Opening : " + filename);
// BufferedReader bufferedReader = new BufferedReader(new FileReader(filename));
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
String line;
while ((line = bufferedReader.readLine()) != null) {
String[] tokens = line.split("\\s+");
add(tokens[0]);
}
}
/**
* Debug.
*/
public void debug() {
System.out.print("debug[WordDictonary] \t ");
Iterator<String> it = strToInt.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
int value = strToInt.get(key);
System.out.println(key + "=" + value + " / " + intToStr.get(value));
}
}
}