public static string ContentsCode(Context context, POSTagger tagger, GrammarParser parser)
        {
            StringBuilder result = new StringBuilder();

            foreach (IContent content in context.Contents)
            {
                string name = content.Name;

                if (content is Variable)
                {
                    IParsedPhrase phrase = ((Variable)content).Produce(context, tagger, parser);
                    if (phrase != null)
                    {
                        name = phrase.Text;
                    }
                }

                if (name[0] == ' ')
                {
                    result.Append(name.Substring(1));
                }
                else
                {
                    if (result.Length > 0)
                    {
                        result.Append(" ");
                    }
                    result.Append(name);
                }
            }

            return(result.ToString());
        }
Exemplo n.º 2
0
        public override bool?IsMatch(IParsedPhrase check)
        {
            List <string> checks = StringUtilities.SplitWords(check.Text.ToLower(), true);

            foreach (List <string> option in options)
            {
                if (option.Count < checks.Count)
                {
                    continue;
                }

                bool sofar = true;
                for (int ii = 0; ii < Math.Min(option.Count, checks.Count); ii++)
                {
                    if (!comparer.Match(checks[ii], option[ii]))
                    {
                        sofar = false;
                        break;
                    }
                }

                if (sofar)
                {
                    if (option.Count == checks.Count)
                    {
                        return(true);
                    }
                    return(null);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        public Concept GetConcept(IParsedPhrase phrase)
        {
            string name = Nouns.AsSubject(phrase.Text);

            if (firstsecond)
            {
                if (name == "I")
                {
                    return(memory.you);
                }
                else if (name == "you")
                {
                    return(memory.self);
                }
            }
            else
            {
                if (name == "I")
                {
                    return(memory.self);
                }
                else if (name == "you")
                {
                    return(memory.you);
                }
            }

            return(memory.NewConcept(phrase));
        }
        public override bool CallRescue(Coderack coderack, IParsedPhrase input, PatternTemplateSource patternTemplateSource, string reason, IContinuation skip, IContinuation succ, IFailure fail)
        {
            List <string> words = GroupPhrase.PhraseToTexts(input);

            bool          changed   = false;
            List <string> corrected = new List <string>();

            foreach (string word in words)
            {
                string correct = comparer.GetCorrects(word)[0];
                if (correct.ToLower() != word.ToLower())
                {
                    changed = true;
                }
                corrected.Add(correct);
            }

            if (changed)
            {
                IParsedPhrase correct  = parser.Parse(StringUtilities.JoinWords(corrected));
                IFailure      fallfail = fallback.MakeFailure(input, patternTemplateSource, succ, fail, coderack);
                patternTemplateSource.Generate(coderack, correct, succ, fallfail, weight);
                return(true);
            }
            else
            {
                return(fallback.CallRescue(coderack, input, patternTemplateSource, reason, skip, succ, fail));
            }
        }
Exemplo n.º 5
0
        public GroupPhrase AddBranch(IParsedPhrase branch)
        {
            List <IParsedPhrase> allbranches = new List <IParsedPhrase>(branches);

            allbranches.Add(branch);
            return(new GroupPhrase(part, allbranches));
        }
Exemplo n.º 6
0
        void DoMatching(List <PatternTemplateSource> dicta, string input)
        {
            if (verbose > 0)
            {
                Console.WriteLine("Parsing input...");
            }
            IParsedPhrase phrase = parser.Parse(input);

            if (verbose > 0)
            {
                Console.WriteLine("Matching templates...");
            }

            // Add a codelet for each of these, to match the input
            if (!serialmode)
            {
                foreach (PatternTemplateSource dictum in dicta)
                {
                    IFailure fail = tryToRescueMatch.MakeFailure(phrase, dictum, this, new NopCallable(), coderack);
                    dictum.Generate(coderack, phrase, this, fail, 1.0);
                }
            }
            else
            {
                SerialTemplateMatcher matcher = new SerialTemplateMatcher(this, this, coderack, tryToRescueMatch, phrase, dicta, 1.0);
                matcher.MatchNextSentence();
            }

            RunToEnd();
        }
        public Concept CompletePartials(Context context)
        {
            if (context.Contents.Count == 0)
            {
                return(null);
            }

            IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);

            if (phrase == null)
            {
                // cannot do!
                context.Map["$knowPartials"] = new List <Datum>();
                return(null);
            }
            Concept concept = memory.NewConcept(phrase);

            List <Datum> completes = context.LookupAndAdd <List <Datum> >("$knowCompletes", new List <Datum>());

            List <Datum> data = context.LookupDefaulted <List <Datum> >("$knowPartials", new List <Datum>());

            foreach (Datum datum in data)
            {
                completes.Add(memory.Know(concept, datum));
            }

            context.Map["$knowPartials"] = new List <Datum>();

            return(concept);
        }
        // Get a part of a parsed phrase-- drop parents when possible, create a new surrounding group when needed
        // start can be negative: count from end
        // count can be negative: use that many less than all the elements
        public static IParsedPhrase GetSubphrase(IParsedPhrase phrase, int start, int count)
        {
            IEnumerable<IParsedPhrase> branches = phrase.Branches;

            List<IParsedPhrase> included = new List<IParsedPhrase>();

            int ii = 0;
            foreach (IParsedPhrase branch in branches)
                if (ii++ >= start)
                    included.Add(branch);

            // start can be negative: count from end
            if (start < 0)
                included = included.GetRange(included.Count + start, -start);
            if (count > 0)
                included = included.GetRange(0, count);
            // count can be negative: less than max elts
            if (count < 0)
                included = included.GetRange(0, included.Count + count);

            if (included.Count == 0)
                return null;    // count <= start!
            if (included.Count == 1)
                return included[0];

            return new GroupPhrase(phrase.Part, included);
        }
        public override bool Match(object check, Context context, IContinuation succ, IFailure fail)
        {
            if (!(check is IParsedPhrase))
            {
                fail.Fail("Cannot match a " + check.GetType(), succ);
                return(true);
            }

            IParsedPhrase phrase = (IParsedPhrase)check;

            if (phrase.Part != "=P")
            {
                fail.Fail("Can only match a paragraph", succ);
                return(true);
            }

            context.Map["$sentences.check"] = check;
            TwoTuple <List <IContent>, IContinuation> parts = SplitArguments(context, succ);
            List <IContent> chunk = parts.one;

            // Match against each element
            int sentenceStart = 0;

            foreach (IParsedPhrase constituent in phrase.Branches)
            {
                Context first = new Context(context, chunk);
                first.Map["$sentences.index"] = sentenceStart + 1;

                Matcher.MatchAgainst(salience, first, constituent, new List <IParsedPhrase>(), parts.two, fail);
            }

            return(true);
        }
Exemplo n.º 10
0
        // Extract the first complete phrase from a string
        public string SingleClause(string input)
        {
            IParsedPhrase phrase = Parse(input);

            if (phrase.Part == "=P") // paragraph
            {
                return(GetSubphrase(phrase, 0, 1).Text);
            }

            if (phrase.Part == "S" || phrase.Part == "SBARQ" ||
                phrase.Part == "SINV" || phrase.Part == "SBAR")
            {
                return(phrase.Text);
            }

            // Otherwise, go to first period
            List <IParsedPhrase> phrases = new List <IParsedPhrase>();

            foreach (IParsedPhrase branch in phrase.Branches)
            {
                phrases.Add(branch);
                if (phrases.Count == 1)
                {
                    continue;   // always add one element
                }
                if (branch.Part == "?" || branch.Part == "!" ||
                    (branch.Part == "." && phrases[phrases.Count - 1].Text.Length > 1))  // watch out for initials!
                {
                    IParsedPhrase first = new GroupPhrase("S", phrases);
                    return(first.Text);
                }
            }

            return(phrase.Text);
        }
        public override bool Match(object check, Context context, IContinuation succ, IFailure fail)
        {
            if (check is IParsedPhrase)
            {
                IParsedPhrase phrase = (IParsedPhrase)check;
                if (phrase.Part == "=P")
                {
                    // Match against each element
                    foreach (IParsedPhrase constituent in phrase.Branches)
                    {
                        Context child = new Context(context, context.Contents);
                        child.Map["$check"] = constituent;
                        ContinueToCallAgent.Instantiate(new ClauseVariable(salience, tagger, parser), child, succ, fail);
                    }
                }
                else if (phrase.Part == "FRAG" || phrase.Part == "S" || phrase.Part == "SBARQ")
                {
                    GroupPhrase   groupPhrase = new GroupPhrase(phrase);
                    IParsedPhrase last        = groupPhrase.GetBranch(groupPhrase.Count - 1);
                    if (last.Part == "." || last.Part == "?" || last.Part == "!" || last.Part == ";")
                    {
                        phrase = new GroupPhrase("?", groupPhrase.GetRange(0));
                    }

                    // Set up propogate-on-clear
                    ContinueToCallAgent cont = CallAgentWrapper.MakeContinuation(PropogateOnClear, succ, 100.0, 4, 10, "%clause", phrase);

                    // Do a match using my contents
                    Matcher.MatchAgainst(salience, context, phrase, new List <IParsedPhrase>(), cont, fail);
                }
            }

            return(true);
        }
        public override bool Match(object check, Context context, IContinuation succ, IFailure fail)
        {
            // XXX: How does childctx get used???
            // Add optional punctuation to end
            Context childctx = new Context(context, context.Contents);

            childctx.Contents.Add(new Special("%opt"));
            childctx.Contents.Add(new Special("%punct"));

            if (check is IParsedPhrase)
            {
                IParsedPhrase phrase = (IParsedPhrase)check;
                if (phrase.Part == "=P")
                {
                    // Match against each element
                    foreach (IParsedPhrase constituent in phrase.Branches)
                    {
                        Matcher.MatchAgainst(salience, context, constituent, new List <IParsedPhrase>(), succ, fail);
                    }

                    return(true);
                }
                else if (phrase.Part == "FRAG" || phrase.Part == "S" || phrase.Part == "SBARQ")
                {
                    // Do a match using my contents
                    Matcher.MatchAgainst(salience, context, (IParsedPhrase)check, new List <IParsedPhrase>(), succ, fail);

                    return(true);
                }
            }

            fail.Fail("Not a sentence.", succ);
            return(true);
        }
        public static void AddEventClause(Context env, IParsedPhrase phrase)
        {
            List <IParsedPhrase> copy = new List <IParsedPhrase>(GetEventClauses(env));

            copy.Add(phrase);
            env.Map["$clause$%event"] = copy;
        }
Exemplo n.º 14
0
        public static void Main(string[] args)
        {
            PluginEnvironment plugenv  = new PluginEnvironment(new MainClass());
            string            plugbase = "/Users/jrising/projects/virsona/github";

            plugenv.Initialize(plugbase + "/config.xml", new NameValueCollection());

            // Test 1: POS Tagging
            POSTagger tagger = new POSTagger(plugenv);
            List <KeyValuePair <string, string> > tagged = tagger.TagList(StringUtilities.SplitWords("This is a test.", false));

            foreach (KeyValuePair <string, string> kvp in tagged)
            {
                Console.WriteLine(kvp.Key + ": " + kvp.Value);
            }

            // Test 2: Grammar parsing
            GrammarParser parser = new GrammarParser(plugenv);
            IParsedPhrase before = parser.Parse("This is a rug and a keyboard.");

            Console.WriteLine(before.ToString());

            // Test 5: Pluralize nouns and conjugate verbs
            Nouns nouns = new Nouns(plugenv);

            Console.WriteLine("person becomes " + nouns.Pluralize("person"));
            Verbs verbs = new Verbs(plugenv);

            Console.WriteLine("goes becomes " + verbs.ComposePast("goes"));
            Console.WriteLine("eats becomes " + verbs.ComposePrespart(verbs.InputToBase("eats")));

            // Test 3: Paraphrasing
            Random randgen = new Random();

            try {
                IParsedPhrase after = parser.Paraphrase(before, null, null, randgen.NextDouble());
                Console.WriteLine(after.Text);
            } catch (Exception ex) {
                Console.WriteLine("Error: " + ex.Message);
            }

            // Test 4: Look up some indices
            WordNetAccess wordnet  = new WordNetAccess(plugenv);
            List <string> synonyms = null;

            try {
                synonyms = wordnet.GetExactSynonyms("rug", WordNetAccess.PartOfSpeech.Noun);
            } catch (Exception ex) {
                Console.WriteLine("Error: " + ex.Message);
            }
            if (synonyms == null)
            {
                Console.WriteLine("Could not find a synonym for 'rug'.  Is Memcached installed?");
            }
            else
            {
                Console.WriteLine("Synonyms: " + string.Join(", ", synonyms.ToArray()));
            }
        }
Exemplo n.º 15
0
 // Don't call this.  Call MatchAgainst
 protected Matcher(double salience, IParsedPhrase input, List<IParsedPhrase> unmatched, IContinuation succ)
     : base(salience, 2 * 4, 10, succ)
 {
     if (input == null)
         throw new NullReferenceException("Input cannot be null.");
     this.input = input;
     this.unmatched = new List<IParsedPhrase>(unmatched);   // make copy, or %opt-fail has effects
 }
        // Adds a codelet to check this input against us
        public void Generate(Coderack coderack, IParsedPhrase input, IContinuation succ, IFailure fail, double weight)
        {
            double salience = maxSalience * score * weight;

            PatternTemplateSource checker = new PatternTemplateSource(this, coderack, salience, succ);

            Matcher.MatchAgainst(salience, pattern, input, new List <IParsedPhrase>(), checker, fail);
        }
        public override bool IsMatch(IParsedPhrase check)
        {
            string words = check.Text;

            return(Verbs.IsModal(words));

            // TODO: better use of "used to" etc, if parsed [ought [to verbx]]
            // TODO: can I encorporate "%is [not] going to"?
        }
        public override bool IsMatch(IParsedPhrase check)
        {
            if (check.IsLeaf)
            {
                return(isVerb(check.Text));
            }

            return(false);
        }
Exemplo n.º 19
0
        public override bool IsMatch(IParsedPhrase check)
        {
            if (variable.IsMatch(check))
            {
                return(declination.IsInDeclination(check));
            }

            return(false);
        }
        public bool IsInDeclination(object value)
        {
            if (value is IParsedPhrase)
            {
                IParsedPhrase phrase = (IParsedPhrase)value;
                return(phrase.Text.ToLower() == phrase.Text);
            }

            return(false);
        }
Exemplo n.º 21
0
 // Don't call this.  Call MatchAgainst
 protected Matcher(double salience, IParsedPhrase input, List <IParsedPhrase> unmatched, IContinuation succ)
     : base(salience, 2 * 4, 10, succ)
 {
     if (input == null)
     {
         throw new NullReferenceException("Input cannot be null.");
     }
     this.input     = input;
     this.unmatched = new List <IParsedPhrase>(unmatched);   // make copy, or %opt-fail has effects
 }
Exemplo n.º 22
0
        // Called by various Produce functions
        public bool ProducePropogated(Context env, string name)
        {
            IParsedPhrase propogated = GetPropogated(env, name);

            if (propogated != null)
            {
                env.Contents.Add(new Value(propogated));
            }

            return(true);
        }
        public static bool KnowPhrase(IParsedPhrase phrase, Context context, Memory memory)
        {
            GroupPhrase   groupPhrase = new GroupPhrase(phrase);
            IParsedPhrase datetime    = groupPhrase.GetBranch(1);

            Datum datum = new Datum(null, Relations.Relation.AtTime, memory.NewConcept(datetime), context.Weight);

            context.LookupAndAdd <List <Datum> >("$knowPartials", new List <Datum>()).Add(datum);

            return(true);
        }
Exemplo n.º 24
0
        bool FailToTryToRescue(IArena arena, double salience, string reason, IContinuation skip, params object[] args)
        {
            TryToRescueMatch      tryToRescueMatch      = (TryToRescueMatch)args[0];
            IParsedPhrase         input                 = (IParsedPhrase)args[1];
            PatternTemplateSource patternTemplateSource = (PatternTemplateSource)args[2];
            IContinuation         succ = (IContinuation)args[3];
            IFailure fail     = (IFailure)args[4];
            Coderack coderack = (Coderack)args[5];

            return(tryToRescueMatch.CallRescue(coderack, input, patternTemplateSource, reason, skip, succ, fail));
        }
        public static bool KnowPhrase(IParsedPhrase phrase, Context context, Memory memory)
        {
            GroupPhrase groupPhrase = new GroupPhrase(phrase);
            IParsedPhrase datetime = groupPhrase.GetBranch(1);

            Datum datum = new Datum(null, Relations.Relation.AtTime, memory.NewConcept(datetime), context.Weight);

            context.LookupAndAdd<List<Datum>>("$knowPartials", new List<Datum>()).Add(datum);

            return true;
        }
        public bool IsInDeclination(object value)
        {
            if (value is IParsedPhrase)
            {
                IParsedPhrase phrase = (IParsedPhrase)value;

                VerbSubVariable checker = new VerbSubVariable("decliner", verbs, pos, inflection);
                return(checker.IsMatch(phrase));
            }

            return(false);
        }
        public object Decline(object value)
        {
            if (value is IParsedPhrase)
            {
                IParsedPhrase phrase = (IParsedPhrase)value;

                string inflected = verbs.InflectVerb(verbs.InputToBase(phrase.Text), inflection);
                return(new WordPhrase(inflected, pos));
            }

            return(value);
        }
Exemplo n.º 28
0
        public virtual bool Match(Context env, IParsedPhrase check)
        {
            if (IsMatch(check))
            {
                Propogate(env, check, 1.0);
                env.Map[StarUtilities.NextStarName(env, name)] = check.Text;

                return true;
            }

            return false;
        }
Exemplo n.º 29
0
        public Concept NewConcept(IParsedPhrase phrase)
        {
            if (phrase.IsLeaf)
            {
                if (phrase.Part.StartsWith("VB"))
                {
                    return(NewConcept(phrase.Text, Concept.Kind.Event));
                }
                else if (phrase.Part == "JJ" || phrase.Part == "RB")
                {
                    return(NewConcept(phrase.Text, Concept.Kind.Attribute));
                }
                else
                {
                    return(NewConcept(phrase.Text, Concept.Kind.Entity));
                }
            }

            GroupPhrase          groupPhrase  = new GroupPhrase(phrase);
            List <IParsedPhrase> constituents = new List <IParsedPhrase>(phrase.Branches);

            // 1. Strip parentheticals
            IParsedPhrase parenthetical = groupPhrase.FindBranch("PRN");

            if (parenthetical != null)
            {
                constituents.Remove(parenthetical);
            }

            // 2. Preposition to contexts, back to front

            /* XXX: Works for "the road of Rome" but not "the city of Rome"
             * while (constituents[constituents.Count - 1] is PrepositionalPhrase)
             * {
             *  context = GetConcept(constituents[constituents.Count - 1], context);
             *  constituents.RemoveAt(constituents.Count - 1);
             * }*/

            IParsedPhrase remain = new GroupPhrase("", constituents);

            if (phrase.Part == "PP")
            {
                return(NewConcept(remain.Text, Concept.Kind.Attribute));
            }
            else if (phrase.Part == "VB")
            {
                return(NewConcept(remain.Text, Concept.Kind.Event));
            }
            else
            {
                return(NewConcept(remain.Text, Concept.Kind.Entity));
            }
        }
        public override bool IsMatch(IParsedPhrase check)
        {
            if (check.Part == "PP") {
                GroupPhrase groupPhrase = new GroupPhrase(check);
                // Take everything except the preposition
                string datetime = groupPhrase.GetBranch(1).Text;

                ProbableStrength time = ValidateUtilities.SeemsTime(datetime);
                return time.IsLikely(0.5);
            } else
                return ValidateUtilities.SeemsSingleDay(check.Text).IsLikely(0.5);
        }
Exemplo n.º 31
0
        public virtual bool Match(Context env, IParsedPhrase check)
        {
            if (IsMatch(check))
            {
                Propogate(env, check, 1.0);
                env.Map[StarUtilities.NextStarName(env, name)] = check.Text;

                return(true);
            }

            return(false);
        }
        public override bool IsMatch(IParsedPhrase check)
        {
            foreach (string part in parts)
            {
                if (check.Part == part)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 33
0
        public void TestLongParse()
        {
            PluginEnvironment plugenv = new PluginEnvironment(this);

            plugenv.Initialize("/Users/jrising/projects/virsona/github/config.xml", new NameValueCollection());

            POSTagger tagger = new POSTagger(plugenv);

            string input = @"2. GENERAL POLICIES--IMMEDIATE AND LONG-RANGE

During the war, production for civilian use was limited by war needs and available manpower. Economic stabilization required measures to spread limited supplies equitably by rationing, price controls, increased taxes, savings bond campaigns, and credit controls. Now, with the surrender of our enemies, economic stabilization requires that policies be directed toward promoting an increase in supplies at low unit prices.
We must encourage the development of resources and enterprises in all parts of the country, particularly in underdeveloped areas. For example, the establishment of new peacetime industries in the Western States and in the South would, in my judgment, add to existing production and markets rather than merely bring about a shifting of production. I am asking the Secretaries of Agriculture, Commerce, and Labor to explore jointly methods for stimulating new industries, particularly in areas with surplus agricultural labor.
We must also aid small businessmen and particularly veterans who are competent to start their own businesses. The establishment and development of efficient small business ventures, I believe, will not take away from, but rather will add to, the total business of all enterprises.
Even with maximum encouragement of production, we cannot hope to remove scarcities within a short time. The most serious deficiencies will persist in the fields of residential housing, building materials, and consumers' durable goods. The critical situation makes continued rent control, price control, and priorities, allocations, and inventory controls absolutely essential. Continued control of consumer credit will help to reduce the pressure on prices of durable goods and will also prolong the period during which the backlog demand will be effective.
While we are meeting these immediate needs we must look forward to a long-range program of security and increased standard of living.
The best protection of purchasing power is a policy of full production and full employment opportunities. Obviously, an employed worker is a better customer than an unemployed worker. There always will be, however, some frictional unemployment. In the present period of transition we must deal with such temporary unemployment as results from the fact that demobilization will proceed faster than reconversion or industrial expansion. Such temporary unemployment is probably unavoidable in a period of rapid change. The unemployed worker is a victim of conditions beyond his control. He should be enabled to maintain a reasonable standard of living for himself and his family.
The most serious difficulty in the path of reconversion and expansion is the establishment of a fair wage structure.
The ability of labor and management to work together, and the wage and price policies which they develop, are social and economic issues of first importance.
Both labor and management have a special interest. Labor's interest is very direct and personal because working conditions, wages, and prices affect the very life and happiness of the worker and his family.
Management has a no less direct interest because on management rests the responsibility for conducting a growing and prosperous business.
But management and labor have identical interests in the long run. Good wages mean good markets. Good business means more jobs and better wages. In this age of cooperation and in our highly organized economy the problems of one very soon become the problems of all.
Better human relationships are an urgent need to which organized labor and management should address themselves. No government policy can make men understand each other, agree, and get along unless they conduct themselves in a way to foster mutual respect and good will.
The Government can, however, help to develop machinery which, with the backing of public opinion, will assist labor and management to resolve their disagreements in a peaceful manner and reduce the number and duration of strikes.
All of us realize that productivity--increased output per man--is in the long run the basis of our standard of living. Management especially must realize that if labor is to work wholeheartedly for an increase in production, workers must be given a just share of increased output in higher wages.
Most industries and most companies have adequate leeway within which to grant substantial wage increases. These increases will have a direct effect in increasing consumer demand to the high levels needed. Substantial wage increases are good business for business because they assure a large market for their products; substantial wage increases are good business for labor because they increase labor's standard of living; substantial wage increases are good business for the country as a whole because capacity production means an active, healthy, friendly citizenry enjoying the benefits of democracy under our free enterprise system.
Labor and management in many industries have been operating successfully under the Government's wage-price policy. Upward revisions of wage scales have been made in thousands of establishments throughout the Nation since VJ-day. It is estimated that about 6 million workers, or more than 20 percent of all employees in nonagricultural and nongovernmental establishments, have received wage increases since August 18, 1945. The amounts of increases given by individual employers concentrate between 10 and 15 percent, but range from less than 5 percent to over 30 percent.
The United States Conciliation Service since VJ-day has settled over 3,000 disputes affecting over 1,300,000 workers without a strike threat and has assisted in settling about 1,300 disputes where strikes were threatened which involved about 500,000 workers. Only workers directly involved, and not those in related industries who might have been indirectly affected, are included in these estimates.
Many of these adjustments have occurred in key industries and would have seemed to us major crises if they had not been settled peaceably.
Within the framework of the wage-price policy there has been definite success, and it is to be expected that this success will continue in a vast majority of the cases arising in the months ahead.
However, everyone who realizes the extreme need for a swift and orderly reconversion must feel a deep concern about the number of major strikes now in progress. If long continued, these strikes could put a heavy brake on our program.
I have already made recommendations to the Congress as to the procedure best adapted to meeting the threat of work stoppages in Nation-wide industries without sacrificing the fundamental rights of labor to bargain collectively and ultimately to strike in support of their position.
If we manage our economy properly, the future will see us on a level of production half again as high as anything we have ever accomplished in peacetime. Business can in the future pay higher wages and sell for lower prices than ever before. This is not true now for all companies, nor will it ever be true for all, but for business generally it is true.
We are relying on all concerned to develop, through collective bargaining, wage structures that are fair to labor, allow for necessary business incentives, and conform with a policy designed to ""hold the line"" on prices.
Production and more production was the byword during the war and still is during the transition from war to peace. However, when deferred demand slackens, we shall once again face the deflationary dangers which beset this and other countries during the 1930's. Prosperity can be assured only by a high level of demand supported by high current income; it cannot be sustained by deferred needs and use of accumulated savings.
If we take the right steps in time we can certainly avoid the disastrous excesses of runaway booms and headlong depressions. We must not let a year or two of prosperity lull us into a false feeling of security and a repetition of the mistakes of the 1920's that culminated in the crash of 1929.
During the year ahead the Government will be called upon to act in many important fields of economic policy from taxation and foreign trade to social security and housing. In every case there will be alternatives. We must choose the alternatives which will best measure up to our need for maintaining production and employment in the future. We must never lose sight of our long-term objectives: the broadening of markets--the maintenance of steadily rising demand. This demand can come from only three sources: consumers, businesses, or government.
In this country the job of production and distribution is in the hands of businessmen, farmers, workers, and professional people -- in the hands of our citizens. We want to keep it that way. However, it is the Government's responsibility to help business, labor, and farmers do their jobs.
There is no question in my mind that the Government, acting on behalf of all the people, must assume the ultimate responsibility for the economic health of the Nation. There is no other agency that can. No other organization has the scope or the authority, nor is any other agency accountable, to all the people. This does not mean that the Government has the sole responsibility, nor that it can do the job alone, nor that it can do the job directly.
All of the policies of the Federal Government must be geared to the objective of sustained full production and full employment--to raise consumer purchasing power and to encourage business investment. The programs we adopt this year and from now on will determine our ability to achieve our objectives. We must continue to pay particular attention to our fiscal, monetary, and tax policy, programs to aid business--especially small business--and transportation, labor-management relations and wage-price policy, social security and health, education, the farm program, public works, housing and resource development, and economic foreign policy.
For example, the kinds of tax measures we have at different times--whether we raise our revenue in a way to encourage consumer spending and business investment or to discourage it--have a vital bearing on this question. It is affected also by regular notions on consumer credit and by the money market, which is strongly influenced by the rate of interest on Government securities. It is affected by almost every step we take.
In short, the way we handle the proper functions of government, the way we time the exercise of our traditional and legitimate governmental functions, has a vital bearing on the economic health of the Nation.
These policies are discussed in greater detail in the accompanying Fifth Quarterly Report of the Director of War Mobilization and Reconversion.";

            Console.WriteLine(Profiler.AnnounceEach());
            List <KeyValuePair <string, string> > tokens = tagger.TagString(input);
            Sentence      sentence = new Sentence(tokens);
            Profiler      timer    = new Profiler();
            IParsedPhrase parsed   = sentence.Parse();

            Console.WriteLine(parsed.ToString());
            Console.WriteLine("Time: " + timer.GetTime());
        }
        public static bool KnowPhrase(IParsedPhrase phrase, Context context, Memory memory)
        {
            if (phrase.Part == "PP")
            {
                Datum datum = new Datum(null, Relations.Relation.InLocation, memory.NewConcept(phrase), context.Weight);

                context.LookupAndAdd <List <Datum> >("$knowPartials", new List <Datum>()).Add(datum);

                return(true);
            }

            return(false);
        }
Exemplo n.º 35
0
        public SerialTemplateMatcher(IMessageReceiver receiver, IContinuation succ, Coderack coderack,
                                     TryToRescueMatch tryToRescueMatch, IParsedPhrase input,
                                     List <PatternTemplateSource> dicta, double weight)
        {
            this.receiver         = receiver;
            this.succ             = succ;
            this.coderack         = coderack;
            this.tryToRescueMatch = tryToRescueMatch;

            this.inputs   = new List <IParsedPhrase>(input.Branches);
            inputIndex    = -1;
            this.allDicta = dicta;
            this.weight   = weight;
        }
        public void PhraseResolveTest()
        {
            // Note that Mary is intentionally mis-tagged, and should not change.
            IParsedPhrase[] phrases = new IParsedPhrase[] {
                new WordPhrase("Mary", "JJ"), new GroupPhrase("VP", new IParsedPhrase[] {
                    new WordPhrase("had", "VBD"), new GroupPhrase("NP", new IParsedPhrase[] {
                        new WordPhrase("a", "DT"), new GroupPhrase("NP", new IParsedPhrase[] {
                            new WordPhrase("little", "??"), new WordPhrase("lamb", "NN")})})})};

            object result = plugenv.ImmediateConvertTo(phrases,
                LanguageNet.Grammarian.POSTagger.TagEnumerationResultType, 1, 1000);
            Assert.IsInstanceOfType(typeof(IEnumerable<string>), result);

            CollectionAssert.AreEqual(new string[] { "JJ", "VBD", "DT", "JJ", "NN" }, (IEnumerable<string>)result);
        }
        public Concept GetConcept(IParsedPhrase phrase)
        {
            string name = Nouns.AsSubject(phrase.Text);

            if (firstsecond)
            {
                if (name == "I")
                    return memory.you;
                else if (name == "you")
                    return memory.self;
            }
            else
            {
                if (name == "I")
                    return memory.self;
                else if (name == "you")
                    return memory.you;
            }

            return memory.NewConcept(phrase);
        }
        public override bool CallRescue(Coderack coderack, IParsedPhrase input, PatternTemplateSource patternTemplateSource, string reason, IContinuation skip, IContinuation succ, IFailure fail)
        {
            List<string> words = GroupPhrase.PhraseToTexts(input);

            bool changed = false;
            List<string> corrected = new List<string>();
            foreach (string word in words) {
                string correct = comparer.GetCorrects(word)[0];
                if (correct.ToLower() != word.ToLower())
                    changed = true;
                corrected.Add(correct);
            }

            if (changed) {
                IParsedPhrase correct = parser.Parse(StringUtilities.JoinWords(corrected));
                IFailure fallfail = fallback.MakeFailure(input, patternTemplateSource, succ, fail, coderack);
                patternTemplateSource.Generate(coderack, correct, succ, fallfail, weight);
                return true;
            } else
                return fallback.CallRescue(coderack, input, patternTemplateSource, reason, skip, succ, fail);
        }
        public override bool? IsMatch(IParsedPhrase check)
        {
            List<string> checks = StringUtilities.SplitWords(check.Text.ToLower(), true);
            foreach (List<string> option in options) {
                if (option.Count < checks.Count)
                    continue;

                bool sofar = true;
                for (int ii = 0; ii < Math.Min(option.Count, checks.Count); ii++)
                    if (!comparer.Match(checks[ii], option[ii])) {
                        sofar = false;
                        break;
                    }

                if (sofar) {
                    if (option.Count == checks.Count)
                        return true;
                    return null;
                }
            }

            return false;
        }
 public override bool IsMatch(IParsedPhrase check)
 {
     return comparer.MatchAny(check.Text, options);
 }
        public override bool? IsMatch(IParsedPhrase check)
        {
            string verb;
            if (check.IsLeaf || !check.Text.Contains(" ")) {
                verb = check.Text;

                if (Verbs.IsToHave(verb)) {
                    if (bases.Contains("have"))
                        return true;
                    else
                        return null;
                }
                if (Verbs.IsToBe(verb)) {
                    if (bases.Contains("be"))
                        return true;
                    else
                        return null;
                }
                if (Verbs.IsToDo(verb)) {
                    if (bases.Contains("do"))
                        return true;
                    else
                        return null;
                }
                if (verb == "will" || verb == "shall")
                    return null; // not sure yet
            } else {
                GroupPhrase groupPhrase = new GroupPhrase(check);
                if (groupPhrase.Count > 2)
                    return false;

                string helper = groupPhrase.GetBranch(0).Text.ToLower();
                verb = groupPhrase.GetBranch(1).Text.ToLower();

                if (!Verbs.IsToHave(helper) && !Verbs.IsToBe(helper) && !Verbs.IsToDo(helper) &&
                    helper != "will" && helper != "shall")
                    return false;
            }

            string baseverb = verbs.InputToBase(verb);
            return (comparer.MatchAny(verb, options) || comparer.MatchAny(verb, bases) ||
                comparer.MatchAny(baseverb, bases));
        }
 public IFailure MakeFailure(IParsedPhrase input, PatternTemplateSource patternTemplateSource, IContinuation succ, IFailure fail, Coderack coderack)
 {
     return new FailletWrapper(FailToTryToRescue, this, input, patternTemplateSource, succ, fail, coderack);
 }
 public override bool IsMatch(IParsedPhrase check)
 {
     return (check.Part == "NN" || check.Part == "NNS" || check.Part == "NP" || check.Part == "NNP" || check.Part == "NNPS");
 }
 public override bool IsMatch(IParsedPhrase check)
 {
     return (check.Part == "PP");
 }
 public override bool IsMatch(IParsedPhrase check)
 {
     return (check.Part == "." || check.Part == "!" || check.Part == "?");
 }
        /***** Static Utility Functions *****/
        // Get the elemental words contained in a parsed phrase
        public static List<string> GetWords(IParsedPhrase phrase)
        {
            List<string> words = new List<string>();
            if (phrase.IsLeaf)
                words.Add(phrase.Text);
            else
            {
                foreach (IParsedPhrase constituent in phrase.Branches)
                    words.AddRange(GetWords(constituent));
            }

            return words;
        }
        // Parapharse a phrase, with a given set of options
        public IParsedPhrase Paraphrase(IParsedPhrase phrase, ParaphraseOptions? options, List<string> emphasizes, double prob)
        {
            ArgumentTree args = new ArgumentTree();
            args["input"] = phrase;
            args["prob"] = prob;
            if (options.HasValue)
                args["opts"] = options.Value;
            if (emphasizes != null)
                args["emph"] = emphasizes;

            ArgumentTree result = (ArgumentTree)plugenv.ImmediateConvertTo(args, GrammarParser.ParaphrasingResultType, 2, 1000 + 100 * phrase.Text.Length);
            return (IParsedPhrase) result.Value;
        }
Exemplo n.º 48
0
 public virtual bool IsMatch(IParsedPhrase check)
 {
     return false;
 }
 public static IParsedPhrase GetSubphrase(IParsedPhrase phrase, int start)
 {
     return GetSubphrase(phrase, start, 0);
 }
        public static void Know(Memory memory, Context context, Relations.Relation kind, IParsedPhrase phrase, double weight, ConceptTranslator produceTranslator)
        {
            Concept concept = produceTranslator.GetConcept(phrase);

            Datum datum = new Datum(null, kind, concept, weight);

            context.LookupAndAdd<List<Datum>>("$knowPartials", new List<Datum>()).Add(datum);
        }
Exemplo n.º 51
0
        public static void MatchAgainst(double salience, Context context, IParsedPhrase input, List<IParsedPhrase> unmatched, IContinuation succ, IFailure fail)
        {
            Evaluator eval = MakeMatcherContinue(salience, context, input, unmatched, succ);

            eval.Continue(context, fail);
        }
 public override bool IsMatch(IParsedPhrase check)
 {
     return (check.Part.StartsWith("VB") && !Verbs.IsToBe(check.Text));
 }
Exemplo n.º 53
0
        public static Evaluator MakeMatcherContinue(double salience, Context context, IParsedPhrase input, List<IParsedPhrase> unmatched, IContinuation succ)
        {
            context.Map["$check"] = null;

            // Match this to first constituent, the continue for others
            Matcher matcheval = new Matcher(salience, input, unmatched, succ);

            ContinuationAppender appender = new ContinuationAppender(context, matcheval);

            Evaluator eval = new Evaluator(salience, ArgumentMode.SingleArgument, appender.AsIndex(0), appender.AsIndex(1), true);

            return eval;
        }
        public override bool IsMatch(IParsedPhrase check)
        {
            if (check.Part == pos)
                return true;

            if (check.Part.StartsWith("VB"))
            {
                return !Verbs.IsToBe(check.Text) && verbs.GetInflection(check.Text) == inflection;
            }
            else
                return false;
        }
        public override bool IsMatch(IParsedPhrase check)
        {
            foreach (string part in parts)
                if (check.Part == part)
                    return true;

            return false;
        }
 public SentenceVariable(double salience, POSTagger tagger, GrammarParser parser, IParsedPhrase final)
     : base(ArgumentMode.RemainderUnevaluated, salience, 8, 10, tagger, parser)
 {
     this.tagger = tagger;
     this.final = final;
 }
        public override bool IsMatch(IParsedPhrase check)
        {
            string words = check.Text;
            return Verbs.IsModal(words);

            // TODO: better use of "used to" etc, if parsed [ought [to verbx]]
            // TODO: can I encorporate "%is [not] going to"?
        }
Exemplo n.º 58
0
        public Concept NewConcept(IParsedPhrase phrase)
        {
            if (phrase.IsLeaf)
            {
                if (phrase.Part.StartsWith("VB"))
                    return NewConcept(phrase.Text, Concept.Kind.Event);
                else if (phrase.Part == "JJ" || phrase.Part == "RB")
                    return NewConcept(phrase.Text, Concept.Kind.Attribute);
                else
                    return NewConcept(phrase.Text, Concept.Kind.Entity);
            }

            GroupPhrase groupPhrase = new GroupPhrase(phrase);
            List<IParsedPhrase> constituents = new List<IParsedPhrase>(phrase.Branches);

            // 1. Strip parentheticals
            IParsedPhrase parenthetical = groupPhrase.FindBranch("PRN");
            if (parenthetical != null)
                constituents.Remove(parenthetical);

            // 2. Preposition to contexts, back to front
            /* XXX: Works for "the road of Rome" but not "the city of Rome"
            while (constituents[constituents.Count - 1] is PrepositionalPhrase)
            {
                context = GetConcept(constituents[constituents.Count - 1], context);
                constituents.RemoveAt(constituents.Count - 1);
            }*/

            IParsedPhrase remain = new GroupPhrase("", constituents);

            if (phrase.Part == "PP")
                return NewConcept(remain.Text, Concept.Kind.Attribute);
            else if (phrase.Part == "VB")
                return NewConcept(remain.Text, Concept.Kind.Event);
            else
                return NewConcept(remain.Text, Concept.Kind.Entity);
        }
        public static bool KnowPhrase(IParsedPhrase phrase, Context context, Memory memory)
        {
            if (phrase.Part == "PP")
            {
                Datum datum = new Datum(null, Relations.Relation.InLocation, memory.NewConcept(phrase), context.Weight);

                context.LookupAndAdd<List<Datum>>("$knowPartials", new List<Datum>()).Add(datum);

                return true;
            }

            return false;
        }
 // default is failure to rescue
 public virtual bool CallRescue(Coderack coderack, IParsedPhrase input, PatternTemplateSource patternTemplateSource, string reason, IContinuation skip, IContinuation succ, IFailure fail)
 {
     return fail.Fail(reason, skip);
 }