当前位置: 首页>>代码示例>>C#>>正文


C# Sentence类代码示例

本文整理汇总了C#中Sentence的典型用法代码示例。如果您正苦于以下问题:C# Sentence类的具体用法?C# Sentence怎么用?C# Sentence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Sentence类属于命名空间,在下文中一共展示了Sentence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Transform

        public override bool Transform(Sentence sentence)
        {
            if (sentence.Complete())
                return true;

            bool success = false;

            KeyValuePair<string, string> nks = NeighborKinds(sentence);

            if (nks.Value == ".") {
                sentence.AbsorbNext(this);
                success = true;
            }

            if (!success && !sentence.Complete()) {
                string last = constituents[constituents.Count - 1].Part;
                if (nks.Key == "" && last == ".")
                {
                    sentence.AddFirstToCompletes();
                    success = true;
                }
                else
                {
                    sentence.Separate(this);
                    success = true;
                }
            }

            return success;
        }
开发者ID:sarang25491,项目名称:Virsona-ChatBot-Tools,代码行数:30,代码来源:SimpleQuestion.cs

示例2: ChildNode

		public ChildNode(Sentence rhs, int startPosition, int endPosition, string id, int rank) : this() {
			Sentence = rhs;
			StartPosition = startPosition;
			EndPosition = endPosition;
			Id = id;
			Rank = rank;
		}
开发者ID:ellisonch,项目名称:CFGLib,代码行数:7,代码来源:ChildNode.cs

示例3: Transform

 public override bool Transform(Sentence sentence)
 {
     List<Phrase> phrases = new List<Phrase>();
     phrases.Add(this);
     sentence.Combine(phrases, new PrepositionalPhrase());
     return true;
 }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:7,代码来源:Preposition.cs

示例4: BuildChildrenHelper

		private static void BuildChildrenHelper(Family family, List<ForestNode[]> startList, Sentence rhs, int position) {
			if (position + 1 != rhs.Count && family.Production != null) {
				throw new Exception();
			}
			if (family.Members.Count == 1) {
				if (position != 0) {
					throw new Exception();
				}
				var onlyNode = family.Members[0];
				AddNode(onlyNode, startList, rhs, position);
			} else if (family.Members.Count == 2) {
				var rightNode = family.Members[1];
				AddNode(rightNode, startList, rhs, position);
				var intermediateNode = (IntermediateNode)family.Members[0];
				var firstCopy = startList.ToList();
				startList.Clear();
				foreach (var subfamily in intermediateNode.Families) {
					var listCopy = firstCopy.ToList();
					BuildChildrenHelper(subfamily, listCopy, rhs, position - 1);
					startList.AddRange(listCopy);
				}
			} else {
				throw new Exception();
			}
		}
开发者ID:ellisonch,项目名称:CFGLib,代码行数:25,代码来源:ForestOption.cs

示例5: standardizeApart

        // Note: see page 327.
        public StandardizeApartResult standardizeApart(Sentence aSentence,
                StandardizeApartIndexical standardizeApartIndexical)
        {
            List<Variable> toRename = variableCollector
                    .collectAllVariables(aSentence);
            Dictionary<Variable, Term> renameSubstitution = new Dictionary<Variable, Term>();
            Dictionary<Variable, Term> reverseSubstitution = new Dictionary<Variable, Term>();

            foreach (Variable var in toRename)
            {
                Variable v = null;
                do
                {
                    v = new Variable(standardizeApartIndexical.getPrefix()
                            + standardizeApartIndexical.getNextIndex());
                    // Ensure the new variable name is not already
                    // accidentally used in the sentence
                } while (toRename.Contains(v));

                renameSubstitution.Add(var, v);
                reverseSubstitution.Add(v, var);
            }

            Sentence standardized = substVisitor.subst(renameSubstitution,
                    aSentence);

            return new StandardizeApartResult(aSentence, standardized,
                    renameSubstitution, reverseSubstitution);
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:30,代码来源:StandardizeApart.cs

示例6: AcceptKnowledge

 public override void AcceptKnowledge(Sentence sentence)
 {
     base.AcceptKnowledge (sentence);
     if(sentence.noun1 != this.gameObject && sentence.verb == Sentence.Verb.Love && sentence.noun2 == wife){
         AddTree(new StalkAndKill(this, "target", sentence.noun1), 20);
     }
 }
开发者ID:rdstn,项目名称:Project,代码行数:7,代码来源:MurdererManager.cs

示例7: convertToCNF

        public CNF convertToCNF(Sentence aSentence)
        {
            // I)mplications Out:
            Sentence implicationsOut = (Sentence)aSentence.accept(
                    new ImplicationsOut(), null);

            // N)egations In:
            Sentence negationsIn = (Sentence)implicationsOut.accept(
                    new NegationsIn(), null);

            // S)tandardize variables:
            // For sentences like:
            // (FORALL x P(x)) V (EXISTS x Q(x)),
            // which use the same variable name twice, change the name of one of the
            // variables.
            Sentence saQuantifiers = (Sentence)negationsIn.accept(
                    new StandardizeQuantiferVariables(substVisitor),
                    new List<Variable>());

            // Remove explicit quantifiers, by skolemizing existentials
            // and dropping universals:
            // E)xistentials Out
            // A)lls Out:
            Sentence andsAndOrs = (Sentence)saQuantifiers.accept(
                    new RemoveQuantifiers(parser), new List<Variable>());

            // D)istribution
            // V over ^:
            Sentence orDistributedOverAnd = (Sentence)andsAndOrs.accept(
                    new DistributeOrOverAnd(), null);

            // O)perators Out
            return (new CNFConstructor()).construct(orDistributedOverAnd);
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:34,代码来源:CNFConverter.cs

示例8: addSentencesToArticle

 private static void addSentencesToArticle(string file, Article article)
 {
     Sentence current = new Sentence();
     string sentence = null;
     string[] words = file.Split('\n');
     for (int i = 0; i < words.Length; i++)
     {
         if (words[i] == "")
         {
             //now we are at the end of a sentence
             if (sentence != null)
             {
                 addWordsToSentence(sentence, current);
                 sentence = null;
                 article.addSentence(current); //add sentence to the article
                 current = new Sentence(); //empty the sentence;
             }
         }
         else
         {
             sentence += (words[i] + '\n'.ToString());
         }
     }
     if (sentence != null) //maybe the last sentence
     {
         addWordsToSentence(sentence, current);
         article.addSentence(current);
     }
 }
开发者ID:yassersouri,项目名称:Corpus-Builder,代码行数:29,代码来源:ArticleUtils.cs

示例9: IsDuplicationSentence

 /// <summary>
 /// 重複したセンテンスであるか
 /// </summary>
 /// <param name="lhs">比較対象1</param>
 /// <param name="rhs">比較対象2</param>
 /// <param name="pattern">パターン</param>
 /// <returns>重複したセンテンスであるか</returns>
 private static bool IsDuplicationSentence(Sentence lhs, Sentence rhs, object[] pattern)
 {
     if (lhs.Tokens.Length < pattern.Length ||
         rhs.Tokens.Length < pattern.Length)
     {
         return false;
     }
     for (int i = 0; i < pattern.Length; i++)
     {
         if (pattern[i] == null)
         {
             continue;
         }
         if (pattern[i] is TokenName && lhs.Tokens[i] is TokenName && rhs.Tokens[i] is TokenName)
         {
             continue;
         }
         if (!lhs.Tokens[i].Equals(pattern[i]))
         {
             return false;
         }
         if (!rhs.Tokens[i].Equals(pattern[i]))
         {
             return false;
         }
     }
     return true;
 }
开发者ID:Roommetro,项目名称:Friendly.WPFStandardControls,代码行数:35,代码来源:GenerateUtility.cs

示例10: ParseGetProbability

		// https://en.wikipedia.org/wiki/CYK_algorithm
		//let the input be a string S consisting of n characters: a1 ... an.
		//let the grammar contain r nonterminal symbols R1 ... Rr.
		//This grammar contains the subset Rs which is the set of start symbols.
		//let P[n,n,r] be an array of booleans. Initialize all elements of P to false.
		//for each i = 1 to n
		//  for each unit production Rj -> ai
		//	set P[1,i,j] = true
		//for each i = 2 to n -- Length of span
		//  for each j = 1 to n-i+1 -- Start of span
		//	for each k = 1 to i-1 -- Partition of span
		//	  for each production RA -> RB RC
		//		if P[k,j,B] and P[i-k,j+k,C] then set P[i,j,A] = true
		//if any of P[n,1,x] is true (x is iterated over the set s, where s are all the indices for Rs) then
		//  S is member of language
		//else
		//  S is not member of language
		/// <summary>
		/// Returns the probability that this grammar generated the given sentence
		/// </summary>
		/// <param name="s"></param>
		/// <returns></returns>
		public override double ParseGetProbability(Sentence s) {
			if (s.Count == 0) {
				return _grammar.ProbabilityNull;
			}

			var nonterminals_R = _grammar.GetNonterminals();
			var RToJ = BuildRToJ(nonterminals_R);

			var P = new double[s.Count, s.Count, nonterminals_R.Count];
			var shouldPunt = CykFillInBase(s, P, RToJ);
			if (shouldPunt) {
				return 0.0;
			}

			var localProductionList = BuildLocalCYKProductionList(RToJ);

			for (int i = 2; i <= s.Count; i++) {
				for (int j = 1; j <= s.Count - i + 1; j++) {
					for (int k = 1; k <= i - 1; k++) {
						foreach (var production in localProductionList) {
							var A = production.A;
							var B = production.B;
							var C = production.C;
							var probThis = production.Probability;

							var pleft = P[k - 1, j - 1, B];
							var pright = P[i - k - 1, j + k - 1, C];
							P[i - 1, j - 1, A] += pleft * pright * probThis;
						}
					}
				}
			}

			return P[s.Count - 1, 0, RToJ[_grammar.Start]];
		}
开发者ID:ellisonch,项目名称:CFGLib,代码行数:57,代码来源:CykParser.cs

示例11: BeginCinematic

    public void BeginCinematic(Type CinematicType)
    {
        // Disable player input
        // Hide castle UI

        // Handle enum types
        switch(CinematicType)
        {
            case Type.HoarderConversation:
                // NOTE (zesty): For special types, always use index 0, the list is used for other types that have
                //  a randomization feature
                Conv = GameData.Cinematics[CinematicType][0];
                break;
            case Type.RandomExclamation:
                Conv = GameData.Cinematics[CinematicType][Random.Range(0, GameData.Cinematics[CinematicType].Count)];
                break;
        }

        // TESTING
        //Conv = GameData.Cinematics[Type.RandomExclamation][3];

        LetterDelay = Conv.LetterDelay;
        TimeToNextLetter = LetterDelay;

        SentenceIndex = 0;
        LetterIndex = 0;
        CurSentence = Conv.Sentences[SentenceIndex];

        CurTextBox = GetTextBox(CurSentence.OwningTextBox);
        SetTextBoxVisible(CurTextBox, true);
        bSentenceComplete = false;

        if(Conv.PauseGame)
            App.inst.SpawnController.PauseEnemiesForCinematic();
    }
开发者ID:clickerdefenseggj,项目名称:clicker-defense,代码行数:35,代码来源:CinematicSet.cs

示例12: Transform

        public override bool Transform(Sentence sentence)
        {
            KeyValuePair<string, string> nks = NeighborKinds(sentence);

            if (nks.Key == "NP" && nks.Value == "NP")
            {
                sentence.Combine(Neighborhood(sentence), new NounPhrase());
                return true;
            }
            else if (nks.Key == "VP" && nks.Value == "VP")
            {
                sentence.Combine(Neighborhood(sentence), new VerbPhrase());
                return true;
            }
            else if (nks.Key == "PP" && nks.Value == "PP")
            {
                sentence.Combine(Neighborhood(sentence), new PrepositionalPhrase());
                return true;
            }
            else if (nks.Key == "S" && nks.Value == "S")
            {
                sentence.Combine(Neighborhood(sentence), new SimpleDeclarativePhrase());
                return true;
            }

            if (nks.Key == "PP" && nks.Value == "NP")
            {
                Phrase preposition = sentence.PhraseBefore(this);
                sentence.AbsorbNext(preposition);   // absorb this
                sentence.AbsorbNext(preposition);   // absorb noun
                return true;
            }

            return false;
        }
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:35,代码来源:Conjunction.cs

示例13: AcceptKnowledge

    private string[] traits; //Used to store the traits in a more convenient way.

    #endregion Fields

    #region Methods

    public override void AcceptKnowledge(Sentence sentence)
    {
        if(!knowledgeBase.ContainsSentence(sentence)){
            if(sentence.noun1 == this.gameObject){
                if(sentence.verb == Sentence.Verb.StayingIn){
                    hotelRoom = sentence.noun2; //CHEAT, can look in knowledgebase to find out
                    AddTree(new DropBags(this, "room", sentence.noun2), 7);
                }
            }

            if(sentence.verb == Sentence.Verb.Love){
                if(sentence.noun1 == SO || sentence.noun2 == SO){
                    if(sentence.noun1 != gameObject && sentence.noun2 != gameObject){
                        if(sentence.noun1 != SO){
                            AddTree(new StalkAndKill(this, "target", sentence.noun1), 30);
                        }
                        else{
                            AddTree(new StalkAndKill(this, "target", sentence.noun2), 30);
                        }
                    }
                }
            }

            if(sentence.verb == Sentence.Verb.Murder && sentence.noun1 != gameObject){
                if(!knowledgeBase.Murdered(gameObject, sentence.noun2)){
                    AddTree(new FoundCorpse(this, receptionist, sentence), 20);
                }
            }
        }
        base.AcceptKnowledge (sentence);
    }
开发者ID:rdstn,项目名称:Project,代码行数:37,代码来源:GuestManager.cs

示例14: IsSentenceValid

        public bool IsSentenceValid(UserProfile profile, Sentence sentence)
        {
            TopicHistoryItem thi = profile.CurrentState.CourseLocationInfo.CurrentTopic;

            bool result = false;

            // deactivate yourself when not in pseudo topic
            if (!thi.IsPseudoTopic)
            {
                result = true;
            }
            else if (thi.WeaknessForPseudoTopic.WeaknessType == WeaknessType.GenderAgreement)
            {
                result = sentence.RoleConjugationPairs.Any(qt => qt.Item2.Gender != GenderRule.Unknown);
            }
            else if (thi.WeaknessForPseudoTopic.WeaknessType == WeaknessType.NumberAgreement)
            {
                result = sentence.RoleConjugationPairs.Any(qt => qt.Item2.Number != NumberRule.Unknown);
            }
            else if(thi.WeaknessForPseudoTopic.WeaknessType == WeaknessType.UmbrellaTopic)
            {
                string umbrellaTopicName = thi.WeaknessForPseudoTopic.UmbrellaTopicName;
                result = sentence.Tags.Any(u => u.Equals(umbrellaTopicName, StringComparison.OrdinalIgnoreCase));
            }

            return result;
        }
开发者ID:usmanghani,项目名称:Quantae,代码行数:27,代码来源:PseudoTopicFilter.cs

示例15: Learn

 public void Learn(Sentence sentence)
 {
     if(sentence.Sentiment == Sentiment.Positive)
     {
         positiveSentances++;
         allCount++;
         for (int i = 0; i < context.SentimentWords.Count; i++)
         {
             var w = context.SentimentWords[i];
             if (!positiveDict.ContainsKey(w))
                 positiveDict.Add(w, new int[2]);
             if (sentence.SentimentWords.Contains(i))
                 positiveDict[w][1]++;
             else
                 positiveDict[w][0]++;
         }
     }
     else
     {
         negtiveSentances++;
         allCount++;
         for (int i = 0; i < context.SentimentWords.Count; i++)
         {
             var w = context.SentimentWords[i];
             if (!negativeDict.ContainsKey(w))
                 negativeDict.Add(w, new int[2]);
             if (sentence.SentimentWords.Contains(i))
                 negativeDict[w][1]++;
             else
                 negativeDict[w][0]++;
         }
     }
 }
开发者ID:rsemenov,项目名称:SentAnalizer,代码行数:33,代码来源:BaesianClassifier.cs


注:本文中的Sentence类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。