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

it.uniroma2.art.semanticturkey.zthes.Zthes Maven / Gradle / Ivy

There is a newer version: 13.1
Show newest version
package it.uniroma2.art.semanticturkey.zthes;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

public class Zthes {
	
	public static class Tag {
		public static final String ZTHES = "Zthes";
	}
	
	private Map termMap; //termId - term
	private Multimap relationMap; //relationType - [termWithThatRelation]
	
	public Zthes() {
		termMap = new HashMap<>();
		relationMap = HashMultimap.create();
	}
	
	public Collection getTerms() {
		return termMap.values();
	}
	
	public Term getTermById(String termId) {
		return termMap.get(termId);
	}
	
	public void addTerm(Term term) {
		termMap.put(term.getTermId(), term);
		//Add the termId-relatedTermId to the map
		for (Relation relation : term.getRelations()) {//for each relation of the term
			RelationType relationType = relation.getRelationType();
			relationMap.put(relationType, term);
		}
	}
	
	public Collection getTermsWithRelation(RelationType relationType) {
		return relationMap.get(relationType);
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy