Example #1
0
 public ParserOptions()
 {
     language       = null;
     engCulture     = new CultureInfo("en-GB");
     spaCulture     = new CultureInfo("es-ES");
     currentCulture = engCulture;
     fileEncoding   = Encoding.UTF8;
     formatInUse    = null;
     parserInUse    = null;
 }
Example #2
0
        //Instance type override, in case a parser instance is passed instead of a string with parser name
        public void SetParser(ClippingsParser parser)
        {
            string t = parser.GetType().ToString();

            if (t == "ParserENG")
            {
                options.SelectedParser = parserENG;
            }
            else if (t == "ParserSPA")
            {
                options.SelectedParser = parserSPA;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Parser instance not recognised: unable to set parser");
            }
        }
Example #3
0
        public bool CheckParserLanguageAndType(ClippingsParser parser, string sample, string preview)
        {
            /// <summary> All parsers inherit from abstract class ClippingsParser. Inheriting parsers need to be
            /// instantiated prior to use. At the moment only ENG and SPA parsers are recognized and used, but the
            /// system should be easily extendable to other languages if needed.
            /// </summary>

            try {
                if (options.Language != null)
                {
                    string        textSample  = sample;
                    List <string> engKeywords = new List <string>();
                    List <string> spaKeywords = new List <string>();

                    /* This lines hunt down an additional keywords (independent of the ones that will be
                     * carried away later) to confirm language. */

                    PickFormatType(preview, options.Language);

                    //A last check that guarantees compatibility.
                    if ((options.Language == "Spanish") && (parser == parserSPA) && (options.SelectedFormat != null))
                    {
                        return(true);
                    }

                    if ((options.Language == "English") && (parser == parserENG) && (options.SelectedFormat != null))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Unable to find language. Have you selected your language?");
                    return(false);
                }
            }

            catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine("Unable to find language. Have you selected your language?" + ex.Message);
                return(false);
            }
        }