Example #1
0
 /// <summary>Create a new search problem, fully specified.</summary>
 /// <seealso cref="ForwardEntailer"/>
 protected internal ForwardEntailerSearchProblem(SemanticGraph parseTree, bool truthOfPremise, int maxResults, int maxTicks, NaturalLogicWeights weights)
 {
     this.parseTree      = parseTree;
     this.truthOfPremise = truthOfPremise;
     this.maxResults     = maxResults;
     this.maxTicks       = maxTicks;
     this.weights        = weights;
 }
Example #2
0
        /// <summary>Create a ne OpenIE system, based on the given properties.</summary>
        /// <param name="props">The properties to parametrize the system with.</param>
        public OpenIE(Properties props)
        {
            //
            // TODO(gabor): handle things like "One example of chemical energy is that found in the food that we eat ."
            //
            //
            // Static Options (for running standalone)
            //
            //
            // Annotator Options (for running in the pipeline)
            //
            // Fill the properties
            ArgumentParser.FillOptions(this, props);
            Properties withoutOpenIEPrefix = new Properties();

            foreach (string key in props.StringPropertyNames())
            {
                withoutOpenIEPrefix.SetProperty(key.Replace("openie.", string.Empty), props.GetProperty(key));
            }
            ArgumentParser.FillOptions(this, withoutOpenIEPrefix);
            // Create the clause splitter
            try
            {
                if (splitterDisable)
                {
                    clauseSplitter = Optional.Empty();
                }
                else
                {
                    if (noModel)
                    {
                        log.Info("Not loading a splitter model");
                        clauseSplitter = Optional.Of(null);
                    }
                    else
                    {
                        clauseSplitter = Optional.Of(IClauseSplitter.Load(splitterModel));
                    }
                }
            }
            catch (IOException e)
            {
                //throw new RuntimeIOException("Could not load clause splitter model at " + splitterModel + ": " + e.getClass() + ": " + e.getMessage());
                throw new RuntimeIOException("Could not load clause splitter model at " + splitterModel, e);
            }
            // Create the forward entailer
            try
            {
                this.weights = ignoreAffinity ? new NaturalLogicWeights(affinityProbabilityCap) : new NaturalLogicWeights(affinityModels, affinityProbabilityCap);
            }
            catch (IOException e)
            {
                throw new RuntimeIOException("Could not load affinity model at " + affinityModels + ": " + e.Message);
            }
            forwardEntailer = new ForwardEntailer(entailmentsPerSentence, weights);
            // Create the relation segmenter
            segmenter = new RelationTripleSegmenter(allNominals);
        }
 /// <seealso cref="ForwardEntailer(int, int, NaturalLogicWeights)"/>
 public ForwardEntailer(int maxResults, NaturalLogicWeights weights)
     : this(maxResults, maxResults * 25, weights)
 {
 }
 /// <seealso cref="ForwardEntailer(int, int, NaturalLogicWeights)"/>
 public ForwardEntailer(NaturalLogicWeights weights)
     : this(int.MaxValue, int.MaxValue, weights)
 {
 }
 /// <summary>Create a new searcher with the specified parameters.</summary>
 /// <param name="maxResults">The maximum number of results to return from a single search.</param>
 /// <param name="maxTicks">The maximum number of ticks to search for.</param>
 /// <param name="weights">The natural logic weights to use for the searches.</param>
 public ForwardEntailer(int maxResults, int maxTicks, NaturalLogicWeights weights)
 {
     this.maxResults = maxResults;
     this.maxTicks   = maxTicks;
     this.weights    = weights;
 }