예제 #1
0
        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);
        }
예제 #2
0
파일: Sequence.cs 프로젝트: zli69/RNNSharp
        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);
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
파일: Sequence.cs 프로젝트: zxz/RNNSharp
        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;
        }