Esempio n. 1
0
        /// <summary> Initializes the data structure for segment positions with given string.</summary>
        /// <param name="str">- the plain string to analyze
        /// </param>
        /// <param name="simti">- SIMple Trie Index
        /// </param>
        public virtual void  init(System.String str, Simti simti)
        {
            int prevIndex = 0;
            int nextIndex = 0;

            positionEnd = 0;
            prevIndex   = addPosition(POSITION_START_KEY);
            position[prevIndex].state = SP_STATE_M;

            System.String rev = "";
            for (int i = str.Length - 1; i >= 0; i--)
            {
                rev += str[i];
            }

            for (int i = 0; i < str.Length; i++)
            {
                char c = str[i];
                nextIndex = addPosition(c);
                setPositionLink(prevIndex, nextIndex);
                prevIndex = nextIndex;

                simti.insert(rev.Substring(0, (str.Length - i) - (0)).ToCharArray(), nextIndex);
            }

            /* for marking the end of the eojeol */
            setPositionLink(prevIndex, 0);
        }
Esempio n. 2
0
        /// <summary> It inserts the reverse of the given string to the SIMTI data structure.</summary>
        /// <param name="str">- string to insert to the SIMTI structure
        /// </param>
        /// <returns> the index of the next morpheme
        /// </returns>
        public virtual int altSegment(System.String str)
        {
            int prev = 0;
            int next = 0;
            int match;
            int len;
            int to;

            len = str.Length;

            System.String rev = "";
            for (int i = len - 1; i >= 0; i--)
            {
                rev += str[i];
            }

            char[] revStrArray = rev.ToCharArray();

            match = simti.search(revStrArray);
            to    = simti.fetch(rev.Substring(0, (match) - (0)).ToCharArray());

            for (int i = 0; i < str.Length; i++)
            {
                if (len <= match)
                {
                    break;
                }
                next = sp.addPosition(str[i]);
                if (prev != 0)
                {
                    sp.setPositionLink(prev, next);
                }

                simti.insert(rev.Substring(0, (len) - (0)).ToCharArray(), next);
                prev = next;
                len--;
            }

            if (prev != 0)
            {
                sp.setPositionLink(prev, to);
            }

            return(simti.fetch(revStrArray));
        }
Esempio n. 3
0
        /// <summary> Initializes the data structure for segment positions with given string.</summary>
        /// <param name="str">- the plain string to analyze
        /// </param>
        /// <param name="simti">- SIMple Trie Index
        /// </param>
        public virtual void init(System.String str, Simti simti)
        {
            int prevIndex = 0;
            int nextIndex = 0;

            positionEnd = 0;
            prevIndex = addPosition(POSITION_START_KEY);
            position[prevIndex].state = SP_STATE_M;

            System.String rev = "";
            for (int i = str.Length - 1; i >= 0; i--)
            {
                rev += str[i];
            }

            for (int i = 0; i < str.Length; i++)
            {
                char c = str[i];
                nextIndex = addPosition(c);
                setPositionLink(prevIndex, nextIndex);
                prevIndex = nextIndex;

                simti.insert(rev.Substring(0, (str.Length - i) - (0)).ToCharArray(), nextIndex);
            }

            /* for marking the end of the eojeol */
            setPositionLink(prevIndex, 0);
        }