public bool SetLabel(Sentence sent, TagSet tagSet) { List <string[]> tokensList = sent.TokensList; if (tokensList.Count != States.Length) { Logger.WriteLine(Logger.Level.warn, String.Format("Error: Inconsistent token({0}) and state({1}) size. Tokens list: {2}", tokensList.Count, States.Length, sent.ToString())); return(false); } for (int i = 0; i < tokensList.Count; i++) { string strTagName = tokensList[i][tokensList[i].Length - 1]; int tagId = tagSet.GetIndex(strTagName); if (tagId < 0) { Logger.WriteLine(Logger.Level.warn, String.Format("Error: tag {0} is unknown. Tokens list: {1}", strTagName, sent.ToString())); return(false); } States[i].Label = tagId; } return(true); }
public bool SetLabel(Sentence sent, TagSet tagSet) { var tokensList = sent.TokensList; if (tokensList.Count != States.Length) { Logger.WriteLine(Logger.Level.warn, $"Error: Inconsistent token({tokensList.Count}) and state({States.Length}) size. Tokens list: {sent}"); return(false); } for (var i = 0; i < tokensList.Count; i++) { var strTagName = tokensList[i][tokensList[i].Length - 1]; var tagId = tagSet.GetIndex(strTagName); if (tagId < 0) { Logger.WriteLine(Logger.Level.warn, $"Error: tag {strTagName} is unknown. Tokens list: {sent}"); return(false); } States[i].Label = tagId; } return(true); }
public void SetLabel(Sentence sent, TagSet tagSet) { List<string[]> tokensList = sent.TokensList; if (tokensList.Count != States.Length) { throw new DataMisalignedException(String.Format("Error: Inconsistent token({0}) and state({1}) size. Tokens list: {2}", tokensList.Count, States.Length, sent.ToString())); } for (int i = 0; i < tokensList.Count; i++) { string strTagName = tokensList[i][tokensList[i].Length - 1]; int tagId = tagSet.GetIndex(strTagName); if (tagId < 0) { throw new DataMisalignedException(String.Format("Error: tag {0} is unknown. Tokens list: {1}", strTagName, sent.ToString())); } States[i].Label = tagId; } }
public void SetLabel(Sentence sent, TagSet tagSet) { List <string[]> tokensList = sent.TokensList; if (tokensList.Count != States.Length) { throw new DataMisalignedException(String.Format("Error: Inconsistent token({0}) and state({1}) size. Tokens list: {2}", tokensList.Count, States.Length, sent.ToString())); } for (int i = 0; i < tokensList.Count; i++) { string strTagName = tokensList[i][tokensList[i].Length - 1]; int tagId = tagSet.GetIndex(strTagName); if (tagId < 0) { throw new DataMisalignedException(String.Format("Error: tag {0} is unknown. Tokens list: {1}", strTagName, sent.ToString())); } States[i].Label = tagId; } }
public bool SetLabel(Sentence sent, TagSet tagSet) { List<string[]> features = sent.GetFeatureSet(); if (features.Count != m_States.Length) { return false; } for (int i = 0; i < features.Count; i++) { string strTagName = features[i][features[i].Length - 1]; int tagId = tagSet.GetIndex(strTagName); if (tagId < 0) { Console.WriteLine("Error: tag {0} is unknown.", strTagName); return false; } m_States[i].SetLabel(tagId); } return true; }