Example #1
0
 private bool LoadPartOfSpeechTagger(string filePath)
 {
     try
     {
         AnsDecoderStream stream = new AnsDecoderStream(
             new FileStream(filePath, FileMode.Open, FileAccess.Read)
             );
         PartOfSpeechTagger = AveragedPerceptronTagger.Load(stream);
         stream.Close();
     }
     catch (IOException)
     {
         return(false);
     }
     return(true);
 }
Example #2
0
        private static bool LoadModel(KeywordPredictorFileMapping mapping)
        {
            IKeywordPredictor predictor = mapping.KeywordPredictorType.GetMethod("GetGlobalModel").Invoke(null, null) as IKeywordPredictor;
            Stream            streamIn  = null;

            try
            {
                streamIn = new AnsDecoderStream(new FileStream(mapping.DefaultFileLocation, FileMode.Open, FileAccess.Read));
            } catch (FileNotFoundException)
            {
                return(false);
            }
            using (streamIn)
            {
                return(predictor.Load(streamIn));
            }
        }
Example #3
0
 public static AveragedPerceptronTagger GetTagger()
 {
     if (Global == null)
     {
         AnsDecoderStream stream;
         try
         {
             stream = new AnsDecoderStream(new FileStream(DefaultModelFileLocations.POS_TAGGER_ENG_FILE, FileMode.Open, FileAccess.Read));
         }
         catch (IOException)
         {
             return(null);
         }
         using (stream)
             Global = Load(stream);
     }
     return(Global);
 }
Example #4
0
        /**
         * Summary:
         *  Loads the the currently selected ProblemPredictor from the file specified
         * Note:
         *  This method does not do the above currently. It is hard coded to use the KNNProblemPredictor.
         *  This is a hold out until the proper method is in place to switch between implementations
         *  through a configuration file.
         */
        private bool LoadProblemPredictor(string filePath)
        {
            ProblemPredictor = new KNNProblemPredictor();
            Stream streamIn;

            try
            {
                streamIn = new AnsDecoderStream(new FileStream(filePath, FileMode.Open, FileAccess.Read));
            } catch (IOException)
            {
                return(false);
            }
            if (!ProblemPredictor.Load(streamIn))
            {
                streamIn.Close();
                ProblemPredictorValid = false;
                return(false);
            }
            streamIn.Close();
            ProblemPredictorValid = true;
            return(true);
        }
Example #5
0
        /**
         * Summary:
         *  Loads the the currently selected KeywordClusterer from the file specified
         * Note:
         *  This method does not do the above currently. It is hard coded to use the KeywordSimilarityClusterer.
         *  This is a hold out until the proper method is in place to switch between implementations
         *  through a configuration file.
         */
        private bool LoadKeywordClusterer(string filePath)
        {
            KeywordClusterer = new KeywordSimilarityClusterer();
            AnsDecoderStream decoderStream;

            try
            {
                decoderStream = new AnsDecoderStream(
                    new FileStream(filePath, FileMode.Open, FileAccess.Read)
                    );
            } catch (IOException)
            {
                return(false);
            }
            if (!KeywordClusterer.Load(decoderStream))
            {
                decoderStream.Close();
                KeywordClustererValid = false;
                return(false);
            }
            decoderStream.Close();
            KeywordClustererValid = true;
            return(true);
        }
Example #6
0
        /**
         * Summary:
         *  Loads the the currently selected KeywordPredictor from the file specified
         * Note:
         *  This method does not do the above currently. It is hard coded to use the NaiveBayesKeywordPredictor.
         *  This is a hold out until the proper method is in place to switch between implementations
         *  through a configuration file.
         */
        private bool LoadKeywordPredictor(string filePath)
        {
            KeywordPredictor = new NaiveBayesKeywordPredictor();
            AnsDecoderStream streamIn;

            try
            {
                streamIn = new AnsDecoderStream(
                    new FileStream(filePath, FileMode.Open, FileAccess.Read)
                    );
            } catch (IOException)
            {
                return(false);
            }
            if (!KeywordPredictor.Load(streamIn))
            {
                streamIn.Close();
                KeywordPredictorValid = false;
                return(false);
            }
            streamIn.Close();
            KeywordPredictorValid = true;
            return(true);
        }