Esempio n. 1
0
            internal HesloveSlovo CloneHesloveSlovo(String item)
            {
                HesloveSlovo hs = new HesloveSlovo(item);

                hs.Odkaz         = this.Odkaz;
                hs.JineCteni     = this.JineCteni;
                hs.NejisteZneni  = this.NejisteZneni;
                hs.NejistyPramen = this.NejistyPramen;
                hs.Odkaz         = this.Odkaz;
                hs.RekonstruovanoZMistnihoJmena = this.RekonstruovanoZMistnihoJmena;
                hs.RuznaPodoba           = this.RuznaPodoba;
                hs.RuznaPodobaVDokladech = this.RuznaPodobaVDokladech;
                hs.Transliterace         = this.Transliterace;
                hs.Varianta       = this.Varianta;
                hs.VychoziPodoba  = this.VychoziPodoba;
                hs.ZenskaPodoba   = this.ZenskaPodoba;
                hs.ZmenenaPdodoba = this.ZmenenaPdodoba;
                hs.ZkracenaForma  = this.ZkracenaForma;
                hs.RozepsanaForma = this.RozepsanaForma;
                hs.Rod            = this.Rod;
                return(hs);
            }
Esempio n. 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;
                }
            }
Esempio n. 3
0
        /// <summary>
        /// Zpravuje heslové slovo, rozdělí jej na jednotlivé části (prefix a postfix) a vygeneruje retrográdní podobu.
        /// </summary>
        /// <param name="strText">Text reprezentující heslové slovo ve slovníku.</param>
        /// <param name="strPrefix">Prefix heslového slova uvedený v atributu prvku hw.</param>
        public bool ZpracujHesloveSlovo(string strText, string strPrefix)
        {
            if (String.IsNullOrEmpty(strText))
            {
                return(false);
            }

            if (strPrefix == null)
            {
                if (!Char.IsLetter(strText, 0))
                {
                    for (int j = 1; j < strText.Length; j++)
                    {
                        if (Char.IsLetter(strText[j]))
                        {
                            strPrefix = strText.Substring(0, j);
                            break;
                        }
                    }
                }
            }
            if (!String.IsNullOrEmpty(strPrefix))
            {
                Prefix       = strPrefix;
                HesloveSlovo = strText.Substring(strPrefix.Length);
            }
            else
            {
                HesloveSlovo = strText;
            }
            if (HesloveSlovo.Contains("(?)"))
            {
                HesloveSlovo.Replace("(?)", "").TrimEnd();
            }

            int i = HesloveSlovo.Length - 1;

            if (i == -1)
            {
                return(false);
            }

            while (!Char.IsLetter(HesloveSlovo, i))
            {
                if (HesloveSlovo[i] == ')' || HesloveSlovo[i] == '-')
                {
                    break;
                }
                Postfix     += HesloveSlovo[i].ToString();
                HesloveSlovo = HesloveSlovo.Substring(0, i);
                i--;
                if (i == -1)
                {
                    break;
                }
            }
            if (i == -1)
            {
                return(false);
            }
            string sRetrograd = Text.Retrograd(HesloveSlovo, true);

            if (sRetrograd.IndexOf(" ") > 0 && !(sRetrograd.Contains(" – ") || sRetrograd.Contains(" - ")))
            {
                Retrograd       = sRetrograd.Substring(sRetrograd.LastIndexOf(" ") + 1);
                RetrogradZbytek = sRetrograd.Substring(0, sRetrograd.LastIndexOf(" "));
            }
            else
            {
                Retrograd = sRetrograd;
            }

            return(true);

            #region Původní kód

            /*
             * if (sRetrograd.IndexOf(" ") > 0 && !(sRetrograd.Contains(" – ") || sRetrograd.Contains(" - "))) {
             *      asVlastnosti[16] = sRetrograd.Substring(sRetrograd.LastIndexOf(" ") + 1);
             *      asVlastnosti[17] = sRetrograd.Substring(0, sRetrograd.LastIndexOf(" "));
             * }
             * else
             *      asVlastnosti[16] = sRetrograd;
             */

            /*
             *                                                                              if (!String.IsNullOrEmpty(sPrefix)) {
             *                                                      asVlastnosti[0] = sPrefix;
             *                                                      asVlastnosti[1] = asVlastnosti[1].Substring(sPrefix.Length);
             *                                              }
             *
             *
             *                                              if (asVlastnosti[1].Contains("(?)")) {
             *                                                      asVlastnosti[1] = asVlastnosti[1].Replace("(?)", "").TrimEnd();
             *                                              }
             *                                              int i = 0;
             *                                              //while (!Char.IsLetter(asVlastnosti[1], i))
             *                                              //{
             *                                              //   asVlastnosti[0] += asVlastnosti[1][i].ToString();
             *                                              //   asVlastnosti[1] = asVlastnosti[1].Substring(1);
             *                                              //   //i++;
             *                                              //}
             *
             *                                              i = asVlastnosti[1].Length - 1;
             *                                              if (i == -1) {
             *                                                      break;
             *                                              }
             *                                              while (!Char.IsLetter(asVlastnosti[1], i)) {
             *                                                      if (asVlastnosti[1][i] == ')' || asVlastnosti[1][i] == '-')
             *                                                              break;
             *                                                      asVlastnosti[2] += asVlastnosti[1][i].ToString();
             *                                                      asVlastnosti[1] = asVlastnosti[1].Substring(0, i);
             *                                                      i--;
             *                                                      if (i == -1) {
             *                                                              break;
             *                                                      }
             *                                              }
             *                                              if (i == -1) {
             *                                                      break;
             *                                              }
             *                                              sRetrograd = Text.Retrograd(asVlastnosti[1], true);
             *
             *                                              if (sRetrograd.IndexOf(" ") > 0 && !(sRetrograd.Contains(" – ") || sRetrograd.Contains(" - "))) {
             *                                                      asVlastnosti[16] = sRetrograd.Substring(sRetrograd.LastIndexOf(" ") + 1);
             *                                                      asVlastnosti[17] = sRetrograd.Substring(0, sRetrograd.LastIndexOf(" "));
             *                                              }
             *                                              else
             *                                                      asVlastnosti[16] = sRetrograd;
             *
             *
             */
            #endregion
        }