Beispiel #1
0
            public void ResetValidator()
            {
                CheckDisposed();

                m_validator = new PhonEnvRecognizer(PhPhoneme.PhonemeRepresentations(m_fdoCache),
                                                    PhNaturalClass.ClassAbbreviations(m_fdoCache));
            }
            public void ResetValidator()
            {
                CheckDisposed();

                m_validator = new PhonEnvRecognizer(
                    m_fdoCache.LangProject.PhonologicalDataOA.AllPhonemes().ToArray(),
                    m_fdoCache.LangProject.PhonologicalDataOA.AllNaturalClassAbbrs().ToArray());
            }
            internal bool CanInsertHashMark()
            {
                CheckDisposed();

                string s = m_env.StringRepresentation.Text;

                if (s == null || s == String.Empty)
                {
                    return(false);
                }
                int ichEnd    = GetSelectionEndPoint(true);
                int ichAnchor = GetSelectionEndPoint(false);

                return(PhonEnvRecognizer.CanInsertHashMark(s, ichEnd, ichAnchor));
            }
Beispiel #4
0
        protected override void LoadParser(ref XmlDocument model, XmlDocument template)
        {
            string hcPath = HcInputPath;

            File.Delete(hcPath);             // In case we don't produce one successfully, don't keep an old one.
            // Check for errors that will prevent the transformations working.
            foreach (var affix in m_cache.ServiceLocator.GetInstance <IMoAffixAllomorphRepository>().AllInstances())
            {
                string form = affix.Form.VernacularDefaultWritingSystem.Text;
                if (string.IsNullOrEmpty(form) || !form.Contains("["))
                {
                    continue;
                }
                string environment = "/_" + form;
                // A form containing a reduplication expression should look like an environment
                var validator = new PhonEnvRecognizer(
                    m_cache.LangProject.PhonologicalDataOA.AllPhonemes().ToArray(),
                    m_cache.LangProject.PhonologicalDataOA.AllNaturalClassAbbrs().ToArray());
                if (!validator.Recognize(environment))
                {
                    string msg = string.Format(ParserCoreStrings.ksHermitCrabReduplicationProblem, form,
                                               validator.ErrorMessage);
                    m_cache.ThreadHelper.Invoke(() =>                     // We may be running in a background thread
                    {
                        MessageBox.Show(Form.ActiveForm, msg, ParserCoreStrings.ksBadAffixForm,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    });
                    m_loader.Reset();           // make sure nothing thinks it is in a useful state
                    return;                     // We can't load the parser, hopefully our caller will realize we failed.
                }
            }

            var transformer = new M3ToHCTransformer(m_projectName, m_taskUpdateHandler);

            transformer.MakeHCFiles(ref model);

            m_patr.LoadGrammarFile(HcGrammarPath);
            m_loader.Load(hcPath);

            XmlNode delReappsNode = model.SelectSingleNode("/M3Dump/ParserParameters/HC/DelReapps");

            if (delReappsNode != null)
            {
                m_loader.CurrentMorpher.DelReapplications = Convert.ToInt32(delReappsNode.InnerText);
            }
        }
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose(bool disposing)
            {
                // Must not be run more than once.
                if (IsDisposed)
                {
                    return;
                }

                base.Dispose(disposing);

                if (disposing)
                {
                }

                m_env       = null;
                m_vc        = null;
                m_validator = null;                 // TODO: Make m_validator disposable?
            }
            internal void ShowEnvironmentError()
            {
                CheckDisposed();

                string s = m_env.StringRepresentation.Text;;

                if (s == null || s == String.Empty)
                {
                    return;
                }
                if (!m_validator.Recognize(s))
                {
                    string sMsg;
                    int    pos = 0;
                    PhonEnvRecognizer.CreateErrorMessageFromXml(s, m_validator.ErrorMessage, out pos, out sMsg);
                    MessageBox.Show(sMsg, MEStrings.ksErrorInEnvironment,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
Beispiel #7
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            base.Dispose(disposing);

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                if (m_PhoneEnvReferenceVc != null)
                {
                    m_PhoneEnvReferenceVc.Dispose();
                }
            }
            m_validator = null;             // TODO: Make m_validator disposable?
            m_realEnvs.Clear();
            m_realEnvs = null;
            m_rootObj  = null;
            if (m_tsf != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_tsf);
            }
            m_tsf      = null;
            m_silCache = null;
            if (m_vwCache != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_vwCache);
            }
            m_vwCache             = null;
            m_PhoneEnvReferenceVc = null;
        }
Beispiel #8
0
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose(bool disposing)
            {
                //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
                // Must not be run more than once.
                if (IsDisposed)
                {
                    return;
                }

                base.Dispose(disposing);

                if (disposing)
                {
                    if (m_vc != null)
                    {
                        m_vc.Dispose();
                    }
                }

                m_env       = null;
                m_vc        = null;
                m_validator = null;                 // TODO: Make m_validator disposable?
            }