Пример #1
0
        internal HeslovaSlova AnalyzujHeslo(XmlWriter xw, string strRadek, ref int iPoradi)
        {
            char[] cchOddelovaceHesel = new char[] { '/', '>', ',' };
            //1. rozdělit řádek na hesla
            //2. analyzovat jednotlivá hesla
            HeslovaSlova glsHeslovaSlova = new HeslovaSlova(strRadek);

            char[] chZnaky = new char[] { ' ', '-', '!', '(', ')', '*', ',', '.', '/', ':', '?', '[', ']', '_', '>' };
            if (strRadek.IndexOfAny(cchOddelovaceHesel) > -1)
            {
                FrekvenceZnaku fz = new FrekvenceZnaku(chZnaky, strRadek.Trim(), true);
                fz.SpocitejFrekvenci();
                if (fz.PoradiZnaku.Contains('>'))
                {
                    string[] asHesla = strRadek.Split(cchOddelovaceHesel, StringSplitOptions.RemoveEmptyEntries);
                    glsHeslovaSlova.Add((new HesloveSlovo(asHesla[0].Trim(), true, false)));
                    glsHeslovaSlova.Add((new HesloveSlovo(asHesla[1].Trim(), false, true)));
                }
                else if (fz.PoradiZnaku == "(/)")
                {
                    string[] asHesla = strRadek.Split(cchOddelovaceHesel, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string sHeslo in asHesla)
                    {
                        if (sHeslo.StartsWith("("))
                        {
                            glsHeslovaSlova.Add((new HesloveSlovo(true, sHeslo.Trim() + ")", "/")));
                        }
                        else
                        {
                            glsHeslovaSlova.Add((new HesloveSlovo(true, "(" + sHeslo.Trim(), "/")));
                        }
                    }
                }
                else if (fz.PoradiZnaku == " (., . ?)")
                {
                    glsHeslovaSlova.Add((new HesloveSlovo(true, strRadek.Trim())));
                }
                else
                {
                    string strOddelovac = ",";
                    if (fz.PoradiZnaku.IndexOf('/') > -1)
                    {
                        strOddelovac = "/";
                    }
                    else if (fz.PoradiZnaku.IndexOf(',') > -1)
                    {
                        strOddelovac = ",";
                    }
                    else
                    {
                        strOddelovac = "";
                    }
                    string[] asHesla = strRadek.Split(cchOddelovaceHesel, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string sHeslo in asHesla)
                    {
                        glsHeslovaSlova.Add((new HesloveSlovo(true, sHeslo.Trim(), strOddelovac)));
                    }
                }
            }
            else
            {
                glsHeslovaSlova.Add(new HesloveSlovo(strRadek));
            }
            glsHeslovaSlova.KonsolidujHesla();

            if (strRadek.IndexOfAny(new char[] { '_', ':' }) == -1)
            {
                VypsatKompletniEntry(xw, strRadek, glsHeslovaSlova, ++iPoradi);
                return(glsHeslovaSlova);
            }
            else
            {
                return(new HeslovaSlova(strRadek));
            }
        }
Пример #2
0
            public void Analyzuj()
            {
                char[] chZnaky = new char[] { ' ', '-', '!', '(', ')', '*', ',', '.', '/', ':', '?', '[', ']', '_', '>' };
                int    i       = 0;

                do
                {
                    FrekvenceZnaku frq = new FrekvenceZnaku(chZnaky, this.Text, true);
                    frq.SpocitejFrekvenci();

                    switch (frq.PoradiZnaku)
                    {
                    case "":
                        this.Heslo = this.Text;
                        break;

                    case "*":
                        this.Heslo = Text.Remove(0, 1);
                        this.RekonstruovanoZMistnihoJmena = true;
                        this.Text = this.Heslo;
                        break;

                    case ":":
                        this.Heslo = Text.Remove(0, 1);
                        this.Odkaz = true;
                        this.Text  = this.Heslo;
                        break;

                    case "_":
                        this.Heslo         = Text.Remove(0, 1);
                        this.Transliterace = true;
                        this.Text          = this.Heslo;
                        break;

                    case "()()":
                    case "()":
                        if (Text.StartsWith("(") && Text.EndsWith(")"))
                        {
                            if (Text.Contains("ová"))
                            {
                                this.ZenskaPodoba = true;
                            }
                            this.Heslo = Text.Substring(1, Text.Length - 2);
                            this.Text  = this.Heslo;
                        }
                        else
                        {
                            this.ZkracenaForma = true;
                            string[] asRozpis = Daliboris.UJC.OVJ.StcS.Slovnik.Pomucky.RozepsatVsechnyZavorky(this.Text);
                            foreach (String item in asRozpis)
                            {
                                HesloveSlovo hs = CloneHesloveSlovo(item);
                                hs.ZkracenaForma  = false;
                                hs.RozepsanaForma = true;
                                this.RozepsanePodoby.Add(hs);
                            }
                            if (this.Heslo == null)
                            {
                                this.Heslo          = this.RozepsanePodoby[0].Original;
                                this.Text           = this.RozepsanePodoby[0].Original;
                                this.ZkracenaForma  = this.RozepsanePodoby[0].ZkracenaForma;
                                this.RozepsanaForma = this.RozepsanePodoby[0].RozepsanaForma;
                                this.RozepsanePodoby.RemoveAt(0);
                            }
                            else
                            {
                                this.Text = string.Empty;
                            }
                        }
                        break;

                    case " (?)":
                        if (this.Text.EndsWith(frq.PoradiZnaku))
                        {
                            this.NejisteZneni = true;
                            this.Heslo        = this.Text.Remove(this.Text.Length - frq.PoradiZnaku.Length);
                            this.Text         = this.Heslo;
                        }
                        break;

                    case " (!)":
                        if (this.Text.EndsWith(frq.PoradiZnaku))
                        {
                            this.NejistyPramen = true;
                            this.Heslo         = this.Text.Remove(this.Text.Length - frq.PoradiZnaku.Length);
                            this.Text          = this.Heslo;
                        }
                        break;

                    case "(.?)":
                    case "() (.)":
                    case " (.  .)":
                    case " (.)":
                        this.Rod   = this.Text.Substring(this.Text.IndexOf(' ') + 1);
                        this.Heslo = this.Text.Remove(this.Text.Length - this.Rod.Length - 1);
                        this.Text  = this.Heslo;
                        break;

                    case "[]":
                        if (Text.StartsWith("[") && Text.EndsWith("]"))
                        {
                            this.JineCteni = true;
                            this.Heslo     = Text.Substring(1, Text.Length - 2);
                            this.Text      = this.Heslo;
                        }
                        break;

                    case "* (?)":
                    case "*()()":
                    case "*()":
                        goto case "*";

                    //break;
                    case " ":
                        this.Heslo = this.Text;
                        break;

                    default:
                        if (this.Text.EndsWith(" (!?)"))
                        {
                            this.NejistyPramen = true;
                            this.NejisteZneni  = true;
                            this.Text          = this.Text.Substring(0, this.Text.Length - " (!?)".Length);
                        }

                        /*
                         * if (this.Text.EndsWith(" (ž.)") || this.Text.EndsWith(" (m.)")) {
                         *      this.Rod = this.Text.Substring(this.Text.Length - " (m.)".Length).Trim();
                         *      this.Text = this.Text.Substring(0, this.Text.Length - " (m.)".Length);
                         * }
                         * else if (this.Text.EndsWith(" (m. nebo ž. ?)")) {
                         *      this.Rod = this.Text.Substring(this.Text.Length - " (m. nebo ž. ?)".Length).Trim();
                         *      this.Text = this.Text.Substring(0, this.Text.Length - " (m. nebo ž. ?)".Length);
                         * }
                         * else if (this.Text.EndsWith(" (m. nebo ž.)")) {
                         *      this.Rod = this.Text.Substring(this.Text.Length - " (m. nebo ž.)".Length).Trim();
                         *      this.Text = this.Text.Substring(0, this.Text.Length - " (m. nebo ž.)".Length);
                         * }
                         * else if (this.Text.EndsWith(" (m. a ž.)")) {
                         *      this.Rod = this.Text.Substring(this.Text.Length - " (m. a ž.)".Length).Trim();
                         *      this.Text = this.Text.Substring(0, this.Text.Length - " (m. a ž.)".Length);
                         * }
                         */
                        if (this.Text.Contains('.'))
                        {
                            string[] asRody = new string[] { " (ž.)", " (m.)", " (m.?)", " (m. ?)", " (ž.?)", "(ž. ?)", " (m., ž.?)", " (m., ž. ?)", " (m. nebo ž. ?)", " (m. nebo ž.)", " (m. a ž.)" };
                            foreach (string sRod in asRody)
                            {
                                if (this.Text.EndsWith(sRod))
                                {
                                    this.Rod  = this.Text.Substring(this.Text.Length - sRod.Length).Trim();
                                    this.Text = this.Text.Substring(0, this.Text.Length - sRod.Length);
                                }
                            }
                        }
                        if (this.Text.EndsWith(" (?)"))
                        {
                            this.NejisteZneni = true;
                            this.Text         = this.Text.Substring(0, this.Text.Length - " (?)".Length);
                        }
                        if (this.Text.EndsWith(" (!)"))
                        {
                            this.NejistyPramen = true;
                            this.Text          = this.Text.Substring(0, this.Text.Length - " (!)".Length);
                        }
                        if (this.Text.StartsWith("[*"))
                        {
                            this.Text = this.Text.Remove(1, 1);
                            this.RekonstruovanoZMistnihoJmena = true;
                        }
                        if (this.Text[0] == '*')
                        {
                            goto case "*";
                        }
                        if (this.Text[0] == '_')
                        {
                            goto case "_";
                        }
                        if (this.Text[0] == ':')
                        {
                            goto case ":";
                        }
                        break;
                    }
                    i++;
                }while (this.Text.IndexOfAny(chZnaky) > -1 && i++ < 5);
                if (this.Text.IndexOfAny(chZnaky) == -1 && this.Heslo == null)
                {
                    this.Heslo = this.Text;
                }
            }