// ********************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="src"></param>
        /// <param name="trn"></param>
        /// <returns></returns>
        /// <created>UPh,29.11.2015</created>
        /// <changed>UPh,29.11.2015</changed>
        // ********************************************************************************
        public void DoCheckTermUsage(string src, string trn, CPAIToken token, CPAITokenCheck checker)
        {
            RangeMap ranges = new RangeMap();

            List <TerminologyResultArgs> results = _Query.RequestSyncTerminology(src, 0);

            int _CurrentFrom = -1;
            int _CurrentLen  = -1;

            string strMissingTerm = "";

            // Results come sorted by word range. Longer sections (number of words in term) come first
            foreach (TerminologyResultArgs result in results)
            {
                if (ranges.OverlapsRange(result.FindFrom, result.FindLen))
                {
                    continue; // Range already checked
                }
                if (_CurrentFrom != result.FindFrom ||
                    _CurrentLen != result.FindLen)
                {
                    if (strMissingTerm.Length > 0)
                    {
                        checker.ErrorOutput(token, string.Format("ET: Missing term {0}", strMissingTerm));
                    }

                    strMissingTerm = "";
                    _CurrentFrom   = result.FindFrom;
                    _CurrentLen    = result.FindLen;
                    strMissingTerm = src.Substring(_CurrentFrom, _CurrentLen);
                }

                if (trn.IndexOf(result.Term2, StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    // Term found. Mark section as ok
                    ranges.AddRange(result.FindFrom, result.FindLen);
                    strMissingTerm = "";
                }
            }

            if (strMissingTerm.Length > 0)
            {
                checker.ErrorOutput(token, string.Format("ET: Missing term {0}", strMissingTerm));
            }
        }
        // ********************************************************************************
        /// <summary>
        /// Checks target language for forbidden terms
        /// </summary>
        /// <param name="src"></param>
        /// <param name="trn"></param>
        /// <param name="token"></param>
        /// <param name="checker"></param>
        /// <created>UPh,20.03.2016</created>
        /// <changed>UPh,20.03.2016</changed>
        // ********************************************************************************
        public void DoCheckProhibitedTerm(string text, CPAIToken token, CPAITokenCheck checker)
        {
            RangeMap ranges = new RangeMap();

            List <TerminologyResultArgs> results = _Query.RequestSyncProhibitedTerminology(text, 0);

            // Results come sorted by word range. Longer sections (number of words in term) come first
            foreach (TerminologyResultArgs result in results)
            {
                if (result.Status != TermStatus.prohibited)
                {
                    continue;
                }

                checker.ErrorOutput(token, string.Format("ET: Prohibited term used: {0}", result.Term1));
            }
        }
Exemple #3
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="src"></param>
        /// <param name="trn"></param>
        /// <returns></returns>
        /// <created>UPh,29.11.2015</created>
        /// <changed>UPh,29.11.2015</changed>
        // ********************************************************************************
        public void DoCheckTermUsage(string src, string trn, CPAIToken token, CPAITokenCheck checker)
        {
            RangeMap ranges = new RangeMap();

            List<TerminologyResultArgs> results = _Query.RequestSyncTerminology(src, 0);

            int _CurrentFrom = -1;
            int _CurrentLen  = -1;

            string strMissingTerm = "";

            // Results come sorted by word range. Longer sections (number of words in term) come first
            foreach (TerminologyResultArgs result in results)
            {
                if (ranges.OverlapsRange(result.FindFrom, result.FindLen))
                    continue; // Range already checked

                if (_CurrentFrom != result.FindFrom ||
                    _CurrentLen  != result.FindLen)
                {
                    if (strMissingTerm.Length > 0)
                        checker.ErrorOutput(token, string.Format("ET: Missing term {0}", strMissingTerm));

                    strMissingTerm = "";
                    _CurrentFrom = result.FindFrom;
                    _CurrentLen  = result.FindLen;
                    strMissingTerm = src.Substring(_CurrentFrom, _CurrentLen);
                }

                if (trn.IndexOf(result.Term2, StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    // Term found. Mark section as ok
                    ranges.AddRange(result.FindFrom, result.FindLen);
                    strMissingTerm = "";
                }
            }

            if (strMissingTerm.Length > 0)
                checker.ErrorOutput(token, string.Format("ET: Missing term {0}", strMissingTerm));
        }
Exemple #4
0
        // ********************************************************************************
        /// <summary>
        /// Checks target language for forbidden terms
        /// </summary>
        /// <param name="src"></param>
        /// <param name="trn"></param>
        /// <param name="token"></param>
        /// <param name="checker"></param>
        /// <created>UPh,20.03.2016</created>
        /// <changed>UPh,20.03.2016</changed>
        // ********************************************************************************
        public void DoCheckProhibitedTerm(string text, CPAIToken token, CPAITokenCheck checker)
        {
            RangeMap ranges = new RangeMap();

            List<TerminologyResultArgs> results = _Query.RequestSyncProhibitedTerminology(text, 0);

            // Results come sorted by word range. Longer sections (number of words in term) come first
            foreach (TerminologyResultArgs result in results)
            {
                if (result.Status != TermStatus.prohibited)
                    continue;

                checker.ErrorOutput(token, string.Format("ET: Prohibited term used: {0}", result.Term1));
            }
        }