コード例 #1
0
        /// <summary>Train a segmenter from raw text.</summary>
        /// <remarks>Train a segmenter from raw text. Gold segmentation markers are required.</remarks>
        public virtual void Train()
        {
            bool hasSegmentationMarkers = true;
            bool hasTags = true;
            IDocumentReaderAndWriter <CoreLabel> docReader = new ArabicDocumentReaderAndWriter(hasSegmentationMarkers, hasTags, hasDomainLabels, domain, noRewrites, tf);
            ObjectBank <IList <CoreLabel> >      lines     = classifier.MakeObjectBankFromFile(flags.trainFile, docReader);

            classifier.Train(lines, docReader);
            log.Info("Finished training.");
        }
コード例 #2
0
        /// <exception cref="System.Exception"/>
        public static void Main(string[] args)
        {
            StringUtils.LogInvocationString(log, args);
            Properties props = StringUtils.ArgsToProperties(args);
            CRFClassifier <CoreLabel> crf = new CRFClassifier <CoreLabel>(props);
            string inputFile = crf.flags.trainFile;

            if (inputFile == null)
            {
                log.Info("Please provide input file using -trainFile");
                System.Environment.Exit(-1);
            }
            string outputFile = crf.flags.exportFeatures;

            if (outputFile == null)
            {
                log.Info("Please provide output file using -exportFeatures");
                System.Environment.Exit(-1);
            }
            Edu.Stanford.Nlp.IE.Crf.CRFFeatureExporter <CoreLabel> featureExporter = new Edu.Stanford.Nlp.IE.Crf.CRFFeatureExporter <CoreLabel>(crf);
            ICollection <IList <CoreLabel> > docs = crf.MakeObjectBankFromFile(inputFile, crf.MakeReaderAndWriter());

            crf.MakeAnswerArraysAndTagIndex(docs);
            featureExporter.PrintFeatures(outputFile, docs);
        }