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


C# Phrase.Add方法代码示例

本文整理汇总了C#中Phrase.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Phrase.Add方法的具体用法?C# Phrase.Add怎么用?C# Phrase.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phrase的用法示例。


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

示例1: Parse

        public static Phrase Parse(IFuzzyState state, Phrase phrase) {
            Match regexMatch = TimeVariableTemporalPrimitiveToken.RegexMatch.Match(phrase.Text);

            if (regexMatch.Success == true) {
                int? hours = regexMatch.Groups["hours"].Value.Length > 0 ? int.Parse(regexMatch.Groups["hours"].Value) : 0;
                int? minutes = regexMatch.Groups["minutes"].Value.Length > 0 ? int.Parse(regexMatch.Groups["minutes"].Value) : 0;
                int? seconds = regexMatch.Groups["seconds"].Value.Length > 0 ? int.Parse(regexMatch.Groups["seconds"].Value) : 0;

                if (String.Compare(regexMatch.Groups["meridiem"].Value, "pm", StringComparison.OrdinalIgnoreCase) == 0 && hours < 12) {
                    hours += 12;
                }
                else if (String.Compare(regexMatch.Groups["meridiem"].Value, "am", StringComparison.OrdinalIgnoreCase) == 0) {
                    if (hours == 12) {
                        hours = 0;
                    }
                }

                hours %= 24;

                phrase.Add(new TimeVariableTemporalPrimitiveToken() {
                    Pattern = new FuzzyDateTimePattern() {
                        Rule = TimeType.Definitive,
                        Hour = (regexMatch.Groups["hours"].Value.Length > 0 ? hours : null),
                        Minute = (regexMatch.Groups["minutes"].Value.Length > 0 ? minutes : null),
                        Second = (regexMatch.Groups["seconds"].Value.Length > 0 ? seconds : null)
                    },
                    Text = phrase.Text,
                    Similarity = 100.0F
                });
            }

            return phrase;
        }
开发者ID:EBassie,项目名称:Potato,代码行数:33,代码来源:TimeVariableTemporalPrimitiveToken.cs

示例2: Parse

        public static Phrase Parse(IFuzzyState state, Phrase phrase) {
            if (phrase.Text.Length > 0 && phrase.Text.First() == '"' && phrase.Text.Last() == '"' && phrase.Refactoring == false) {
                phrase.Add(new StringPrimitiveToken() {
                    Text = phrase.Text.Trim('"'),
                    Similarity = 80,
                    Value = phrase.Text.Trim('"')
                });
            }

            return phrase;
        }
开发者ID:EBassie,项目名称:Potato,代码行数:11,代码来源:StringPrimitiveToken.cs

示例3: Parse

        public static Phrase Parse(IFuzzyState state, Phrase phrase) {
            Match regexMatch = DateVariableTemporalPrimitiveToken.RegexMatch.Match(phrase.Text);

            if (regexMatch.Success == true) {
                DateTime dt;
                if (DateTime.TryParse(phrase.Text, out dt) == true) {
                    phrase.Add(new DateVariableTemporalPrimitiveToken() {
                        Pattern = new FuzzyDateTimePattern() {
                            Rule = TimeType.Definitive,
                            Year = dt.Year,
                            Month = dt.Month,
                            Day = dt.Day
                        },
                        Text = phrase.Text,
                        Similarity = 100.0F
                    });
                }
            }

            return phrase;
        }
开发者ID:EBassie,项目名称:Potato,代码行数:21,代码来源:DateVariableTemporalPrimitiveToken.cs

示例4: Process

 /**
 * Process the text so that it will render with a combination of fonts
 * if needed.
 * @param text the text
 * @return a <CODE>Phrase</CODE> with one or more chunks
 */
 public virtual Phrase Process(String text) {
     if (fonts.Count == 0)
         throw new ArgumentOutOfRangeException(MessageLocalization.GetComposedMessage("no.font.is.defined"));
     char[] cc = text.ToCharArray();
     int len = cc.Length;
     StringBuilder sb = new StringBuilder();
     Phrase ret = new Phrase();
     currentFont = null;
     for (int k = 0; k < len; ++k) {
         Chunk newChunk = ProcessChar(cc, k, sb);
         if (newChunk != null) {
             ret.Add(newChunk);
         }
     }
     if (sb.Length > 0) {
         Chunk ck = new Chunk(sb.ToString(), currentFont ?? fonts[0]);
         ret.Add(ck);
     }
     return ret;
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:26,代码来源:FontSelector.cs

示例5: GetPhrase

 public static Phrase GetPhrase(Properties attributes)
 {
     Phrase phrase = new Phrase();
     phrase.Font = FontFactory.GetFont(attributes);
     String value;
     value = attributes[ElementTags.LEADING];
     if (value != null) {
         phrase.Leading = float.Parse(value, NumberFormatInfo.InvariantInfo);
     }
     value = attributes[Markup.CSS_KEY_LINEHEIGHT];
     if (value != null) {
         phrase.Leading = Markup.ParseLength(value, Markup.DEFAULT_FONT_SIZE);
     }
     value = attributes[ElementTags.ITEXT];
     if (value != null) {
         Chunk chunk = new Chunk(value);
         if ((value = attributes[ElementTags.GENERICTAG]) != null) {
             chunk.SetGenericTag(value);
         }
         phrase.Add(chunk);
     }
     return phrase;
 }
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:23,代码来源:ElementFactory.cs

示例6: GetTokens

        public static Phrase GetTokens(this Tree tree, Tree root = null, Rhetorica.Sentence sentence = null, string ignore = "", string punctuation = null, AnalyzerOptions options = AnalyzerOptions.None)
        {
            var tokens = new Phrase(sentence: sentence);
              java.util.List leaves = tree.getLeaves();

              for (java.util.Iterator i = leaves.iterator(); i.hasNext(); ) {
            Tree leaf = (Tree)i.next();
            string token = leaf.value().Trim();

            Tree preterminal = leaf.parent(tree);
            if (preterminal == null)
              continue;
            string tag = preterminal.value().Trim();

            bool ignoreMeansInclude = options.HasFlag(AnalyzerOptions.IgnoreMeansInclude);
            if (ignore != string.Empty) {
              bool isMatch = Regex.IsMatch(token, ignore);
              if (ignoreMeansInclude) {
            if (!isMatch) continue;
              }
              else {
            if (isMatch) continue;
              }
            }

            bool omitPunctuation = options.HasFlag(AnalyzerOptions.OmitPunctuationTokens);
            if (omitPunctuation) {
              // Leave out certain types of punctuation:
              bool isPunctuation = Regex.IsMatch(tag, punctuation ?? Analyzer.PunctuationPatterns)
            || Regex.IsMatch(token, punctuation ?? Analyzer.PunctuationPatterns);
              if (isPunctuation) {
            tokens.IsPunctuationOmitted = true;
            continue;
              }

              // But also remove any straggler punctuation missed within a token...? Maybe not. Use RegExp 'FloatingPunctuationPatterns' if so.
            }

            root = root ?? tree;
            int depth = root.depth() - root.depth(preterminal);

            var characterEdges = new CharacterEdges(root.leftCharEdge(leaf), root.rightCharEdge(leaf));
            tokens.Add(new Token(token, tag, depth, characterEdges));
              }

              return tokens;
        }
开发者ID:priscian,项目名称:rhetorica,代码行数:47,代码来源:RhetoricaExtensionMethods.cs

示例7: ParsePhrase

		/// <summary>
		/// Parses a script from the specified resource.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="rawPhrase">The phrase which to parse.</param>
		/// <returns>Returns the parsed script.</returns>
		/// <exception cref="ParseScriptException">Thrown when an exception occurres while parsing the script.</exception>
		private Phrase ParsePhrase(IMansionContext context, string rawPhrase)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (rawPhrase == null)
				throw new ArgumentNullException("rawPhrase");

			// create a new phrase
			var phrase = new Phrase();

			// tokenize the raw phrase into smaller sections
			foreach (var token in tokenizer.Tokenize(context, rawPhrase))
			{
				// get the interpreter for this input
				var interpreter = Election<ExpressionPartInterpreter, string>.Elect(context, interpreters, token);

				// interpret the token
				phrase.Add(interpreter.Interpret(context, token));
			}

			// return the parsed phrase
			return phrase;
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:31,代码来源:ExpressionScriptService.cs

示例8: Process

 /**
 * Process the text so that it will render with a combination of fonts
 * if needed.
 * @param text the text
 * @return a <CODE>Phrase</CODE> with one or more chunks
 */
 public Phrase Process(String text)
 {
     int fsize = fonts.Count;
     if (fsize == 0)
         throw new ArgumentException("No font is defined.");
     char[] cc = text.ToCharArray();
     int len = cc.Length;
     StringBuilder sb = new StringBuilder();
     Font font = null;
     int lastidx = -1;
     Phrase ret = new Phrase();
     for (int k = 0; k < len; ++k) {
         char c = cc[k];
         if (c == '\n' || c == '\r') {
             sb.Append(c);
             continue;
         }
         if (Utilities.IsSurrogatePair(cc, k)) {
             int u = Utilities.ConvertToUtf32(cc, k);
             for (int f = 0; f < fsize; ++f) {
                 font = (Font)fonts[f];
                 if (font.BaseFont.CharExists(u)) {
                     if (lastidx != f) {
                         if (sb.Length > 0 && lastidx != -1) {
                             Chunk ck = new Chunk(sb.ToString(), (Font)fonts[lastidx]);
                             ret.Add(ck);
                             sb.Length = 0;
                         }
                         lastidx = f;
                     }
                     sb.Append(c);
                     sb.Append(cc[++k]);
                     break;
                 }
             }
         }
         else {
             for (int f = 0; f < fsize; ++f) {
                 font = (Font)fonts[f];
                 if (font.BaseFont.CharExists(c)) {
                     if (lastidx != f) {
                         if (sb.Length > 0 && lastidx != -1) {
                             Chunk ck = new Chunk(sb.ToString(), (Font)fonts[lastidx]);
                             ret.Add(ck);
                             sb.Length = 0;
                         }
                         lastidx = f;
                     }
                     sb.Append(c);
                     break;
                 }
             }
         }
     }
     if (sb.Length > 0) {
         Chunk ck = new Chunk(sb.ToString(), (Font)fonts[lastidx == -1 ? 0 : lastidx]);
         ret.Add(ck);
     }
     return ret;
 }
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:66,代码来源:FontSelector.cs


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