// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java
// public interface ConceptDrugDatabaseInterface {
// 
// 	/*
// 	 * get name of file that will contain the prediction matrix generated by
// 	 * algorithm
// 	 */
// 	public String getMatrixFileName();
// 
// 	/*
// 	 * Method to get all the medical records containing encounterId(integer that
// 	 * represent an id for prescriptions written for a patient),
// 	 * ConceptId(integer that represent a diagnosis/diseases/observation for
// 	 * patient has been treated), DrugId(integer representing a drug that was
// 	 * written in the prescription)
// 	 */
// 	public LinkedList<EncounterIdConceptDrug> getData();
// 
// 	/*
// 	 * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId,
// 	 * and feature related to medical records like age of patient, location of doctor/patient etc.
// 	 */
// 	
// 	public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids);
// 
// 	/*
// 	 * Method to get the list of conceptId and concept_name for given list of conceptId(integer)
// 	 */
// 	
// 	public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of Drugs for given drugIds(integers)
// 	 */
// 	public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of all conceptId and concept_words
// 	 */
// 	public LinkedList<ConceptWordModel> getConceptWords();
// }
// 
// Path: src/com/learningmodule/association/conceptdrug/model/ConceptWordModel.java
// public class ConceptWordModel {
// 	private String conceptId;
// 	private String conceptWord;
// 
// 	public ConceptWordModel(String conceptId, String conceptWord) {
// 		super();
// 		this.conceptId = conceptId;
// 		this.conceptWord = conceptWord;
// 	}
// 
// 	public String getConceptId() {
// 		return conceptId;
// 	}
// 
// 	public String getConceptWord() {
// 		return conceptWord;
// 	}
// }


import java.util.LinkedList;
import org.apache.log4j.Logger;
import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface;
import com.learningmodule.association.conceptdrug.model.ConceptWordModel;
package com.learningmodule.association.conceptdrug.search;




/*
 * Class that implements method to get the Approximate String matches using Levenshtien Distance
 * for a string and to make the Dictionary
 * link of the algorithm explanation http://stevehanov.ca/blog/index.php?id=114
 */

public class LevenshteinSearch {
	
	// root node of the Trie
	private TrieNode trie;
	
	private Logger log = Logger.getLogger(LevenshteinSearch.class);
	
	// database interface to get dictionary for concept words
	private ConceptDrugDatabaseInterface learningInterface;
	
	// constructor for this class
	public LevenshteinSearch(ConceptDrugDatabaseInterface learningInterface) {
		this.learningInterface = learningInterface;
		
		// make the dictionary when Object is created
		makeDictionary();
	}
	/*
	 * Method that will construct the dictionary by getting all the
	 * concept_words from database
	 */
	public void makeDictionary() {

		// get the list of words from database
// Path: src/com/learningmodule/association/conceptdrug/ConceptDrugDatabaseInterface.java
// public interface ConceptDrugDatabaseInterface {
// 
// 	/*
// 	 * get name of file that will contain the prediction matrix generated by
// 	 * algorithm
// 	 */
// 	public String getMatrixFileName();
// 
// 	/*
// 	 * Method to get all the medical records containing encounterId(integer that
// 	 * represent an id for prescriptions written for a patient),
// 	 * ConceptId(integer that represent a diagnosis/diseases/observation for
// 	 * patient has been treated), DrugId(integer representing a drug that was
// 	 * written in the prescription)
// 	 */
// 	public LinkedList<EncounterIdConceptDrug> getData();
// 
// 	/*
// 	 * Method to get the medical records with given list of concepts Ids contaning encounterId, conceptId, DrugId,
// 	 * and feature related to medical records like age of patient, location of doctor/patient etc.
// 	 */
// 	
// 	public LinkedList<EncounterIdConceptFeaturesDrugModel> getDataByConceptIds(LinkedList<String> ids);
// 
// 	/*
// 	 * Method to get the list of conceptId and concept_name for given list of conceptId(integer)
// 	 */
// 	
// 	public LinkedList<ConceptNameModel> getConceptIdNameByConceptIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of Drugs for given drugIds(integers)
// 	 */
// 	public LinkedList<AbstractDrugModel> getDrugInfoByDrugIds(LinkedList<String> conceptIds);
// 
// 	/*
// 	 * Method to get the list of all conceptId and concept_words
// 	 */
// 	public LinkedList<ConceptWordModel> getConceptWords();
// }
// 
// Path: src/com/learningmodule/association/conceptdrug/model/ConceptWordModel.java
// public class ConceptWordModel {
// 	private String conceptId;
// 	private String conceptWord;
// 
// 	public ConceptWordModel(String conceptId, String conceptWord) {
// 		super();
// 		this.conceptId = conceptId;
// 		this.conceptWord = conceptWord;
// 	}
// 
// 	public String getConceptId() {
// 		return conceptId;
// 	}
// 
// 	public String getConceptWord() {
// 		return conceptWord;
// 	}
// }


// Path: src/com/learningmodule/association/conceptdrug/search/LevenshteinSearch.java
import java.util.LinkedList;
import org.apache.log4j.Logger;
import com.learningmodule.association.conceptdrug.ConceptDrugDatabaseInterface;
import com.learningmodule.association.conceptdrug.model.ConceptWordModel;

package com.learningmodule.association.conceptdrug.search;




/*
 * Class that implements method to get the Approximate String matches using Levenshtien Distance
 * for a string and to make the Dictionary
 * link of the algorithm explanation http://stevehanov.ca/blog/index.php?id=114
 */

public class LevenshteinSearch {
	
	// root node of the Trie
	private TrieNode trie;
	
	private Logger log = Logger.getLogger(LevenshteinSearch.class);
	
	// database interface to get dictionary for concept words
	private ConceptDrugDatabaseInterface learningInterface;
	
	// constructor for this class
	public LevenshteinSearch(ConceptDrugDatabaseInterface learningInterface) {
		this.learningInterface = learningInterface;
		
		// make the dictionary when Object is created
		makeDictionary();
	}
	/*
	 * Method that will construct the dictionary by getting all the
	 * concept_words from database
	 */
	public void makeDictionary() {

		// get the list of words from database
		LinkedList<ConceptWordModel> names = learningInterface.getConceptWords();