/// <summary> /// return a clone of the new bucket /// </summary> /// <param name="token"></param> /// <returns></returns> public override LexiconToken getClone(LexiconToken token) { LexiconPredicate predicateToReplace = new LexiconPredicate(); predicateToReplace.URI = token.URI; predicateToReplace.label = token.label; predicateToReplace.ranges = (token as LexiconPredicate).ranges.ToList(); predicateToReplace.QuestionMatch = token.QuestionMatch; predicateToReplace.score = token.score; predicateToReplace.domains = (token as LexiconPredicate).domains.ToList(); return predicateToReplace; }
/// <summary> /// return a clone of the token send to the function /// </summary> /// <param name="token"></param> /// <returns></returns> public override LexiconToken getClone(LexiconToken token) { LexiconLiteral literalToReplace = new LexiconLiteral(); literalToReplace.URI = token.URI; literalToReplace.label = token.label; literalToReplace.typeOfOwner = (token as LexiconLiteral).typeOfOwner.ToList(); literalToReplace.QuestionMatch = token.QuestionMatch; literalToReplace.score = token.score; return(literalToReplace); }
/// <summary> /// Checks if there is a token already exists in the consumed tokens list that has same identifier /// </summary> /// <param name="token">the token to compare to </param> /// <returns>true or false</returns> public bool ContainsTokenWithSameIdentifier(LexiconToken token) { //todo: //foreach (LexiconToken item in tokens) //{ // if (token.identifier.Equals(item.identifier)) // return true; //} //return false; return(false); }
/// <summary> /// Checks if there is a token already exists in the consumed tokens list /// that connects the same URIs (has same range and domain) /// </summary> /// <param name="token">the lexicon token to compare to</param> /// <returns>true or false</returns> public bool ContainsTokenWithSameURIs(LexiconToken token) { foreach (var instance in tokens) { if (token.URI.Equals(instance.URI)) { return(true); } } return(false); }
/// <summary> /// return a clone of the new bucket /// </summary> /// <param name="token"></param> /// <returns></returns> public override LexiconToken getClone(LexiconToken token) { LexiconPredicate predicateToReplace = new LexiconPredicate(); predicateToReplace.URI = token.URI; predicateToReplace.label = token.label; predicateToReplace.ranges = (token as LexiconPredicate).ranges.ToList(); predicateToReplace.QuestionMatch = token.QuestionMatch; predicateToReplace.score = token.score; predicateToReplace.domains = (token as LexiconPredicate).domains.ToList(); return(predicateToReplace); }
public abstract LexiconToken getClone(LexiconToken token);
/// <summary> /// return a clone of the token send to the function /// </summary> /// <param name="token"></param> /// <returns></returns> public override LexiconToken getClone(LexiconToken token) { LexiconLiteral literalToReplace = new LexiconLiteral(); literalToReplace.URI = token.URI; literalToReplace.label = token.label; literalToReplace.typeOfOwner = (token as LexiconLiteral).typeOfOwner.ToList(); literalToReplace.QuestionMatch = token.QuestionMatch; literalToReplace.score = token.score; return literalToReplace; }
/// <summary> /// Checks if there is a token already exists in the consumed tokens list /// that connects the same URIs (has same range and domain) /// </summary> /// <param name="token">the lexicon token to compare to</param> /// <returns>true or false</returns> public bool ContainsTokenWithSameURIs(LexiconToken token) { foreach (var instance in tokens) { if (token.URI.Equals(instance.URI)) return true; } return false; }
/// <summary> /// Checks if there is a token already exists in the consumed tokens list that has same identifier /// </summary> /// <param name="token">the token to compare to </param> /// <returns>true or false</returns> public bool ContainsTokenWithSameIdentifier(LexiconToken token) { //todo: //foreach (LexiconToken item in tokens) //{ // if (token.identifier.Equals(item.identifier)) // return true; //} //return false; return false; }
/// <summary> /// adds a new token to the bucket /// </summary> /// <param name="token">the token to add to the bucket</param> /// <returns>if it was added successfully</returns> public bool add(LexiconToken token) { ///*If this token has domain and range(is a connector token or predicate) i.e. uriList size > 1, // *check all URIs of that token are already present in any token in the tokens hashtable // *If already present, dont add (return false)*/ ////if ((uriList.Count > 1) && (this.ContainsTokenWithSameURIs(token))) //// return false; //check whether any URI of token is contained in the uriToDo vector //but only if there is already something in the uriToDo vector or in the uriUsed hashtable bool inToDo; bool inURIUsed; if ((uriToDo.Count > 0) || (uriUsed.Count > 0)) /////////////////To be checked again { inToDo = false; if (uriToDo.Contains(token.URI)) inToDo = true; inURIUsed = false; if (uriUsed.Contains(token.URI)) inURIUsed = true; if (!inToDo && !inURIUsed) return false; } //will reduce the questionleft according to the questionmatch questionLeft = questionMatch(token.QuestionMatch); questionLeft = questionLeft.Trim(); //adding the token to the token list tokens.Add(token); //if this token has an uri in it that is part of the uriToDo Vector, //remove it from the vector an move it into the uriUsed Hashtable, //else if the uri is already contained in the uriUsed Hashtable do nothing //else put it into the uriToDo Vector for (int i = 0; i < uriToDo.Count; i++) { if (uriToDo[i].Equals(token.URI)) uriToDo.Remove(uriToDo[i]); uriUsed.Add(token.URI); } bool virginURI = true; for (int i = 0; i < uriUsed.Count; i++) { if (uriUsed[i].Equals(token.URI)) virginURI = false; } if (!virginURI) uriToDo.Add(token.URI); //------------------------------------------------------------------ return true; }
/// <summary> /// adds a new token to the bucket /// </summary> /// <param name="token">the token to add to the bucket</param> /// <returns>if it was added successfully</returns> public bool add(LexiconToken token) { ///*If this token has domain and range(is a connector token or predicate) i.e. uriList size > 1, // *check all URIs of that token are already present in any token in the tokens hashtable // *If already present, dont add (return false)*/ ////if ((uriList.Count > 1) && (this.ContainsTokenWithSameURIs(token))) //// return false; //check whether any URI of token is contained in the uriToDo vector //but only if there is already something in the uriToDo vector or in the uriUsed hashtable bool inToDo; bool inURIUsed; if ((uriToDo.Count > 0) || (uriUsed.Count > 0)) /////////////////To be checked again { inToDo = false; if (uriToDo.Contains(token.URI)) { inToDo = true; } inURIUsed = false; if (uriUsed.Contains(token.URI)) { inURIUsed = true; } if (!inToDo && !inURIUsed) { return(false); } } //will reduce the questionleft according to the questionmatch questionLeft = questionMatch(token.QuestionMatch); questionLeft = questionLeft.Trim(); //adding the token to the token list tokens.Add(token); //if this token has an uri in it that is part of the uriToDo Vector, //remove it from the vector an move it into the uriUsed Hashtable, //else if the uri is already contained in the uriUsed Hashtable do nothing //else put it into the uriToDo Vector for (int i = 0; i < uriToDo.Count; i++) { if (uriToDo[i].Equals(token.URI)) { uriToDo.Remove(uriToDo[i]); } uriUsed.Add(token.URI); } bool virginURI = true; for (int i = 0; i < uriUsed.Count; i++) { if (uriUsed[i].Equals(token.URI)) { virginURI = false; } } if (!virginURI) { uriToDo.Add(token.URI); } //------------------------------------------------------------------ return(true); }