本文整理汇总了C#中Phrase类的典型用法代码示例。如果您正苦于以下问题:C# Phrase类的具体用法?C# Phrase怎么用?C# Phrase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Phrase类属于命名空间,在下文中一共展示了Phrase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReduceDividendForwardSlashDivisor
public static Phrase ReduceDividendForwardSlashDivisor(IFuzzyState state, Dictionary<String, Token> parameters) {
FloatNumericPrimitiveToken dividend = (FloatNumericPrimitiveToken) parameters["dividend"];
ForwardSlashPunctuationSyntaxToken forwardSlash = (ForwardSlashPunctuationSyntaxToken) parameters["forwardSlash"];
FloatNumericPrimitiveToken divisor = (FloatNumericPrimitiveToken) parameters["divisor"];
Phrase phrase = null;
if (divisor.ToFloat() != 0.0F) {
phrase = new Phrase() {
new FloatNumericPrimitiveToken() {
Value = dividend.ToFloat() / divisor.ToFloat(),
Text = String.Format("{0} {1} {2}", dividend.Text, forwardSlash.Text, divisor.Text),
Similarity = (dividend.Similarity + forwardSlash.Similarity + divisor.Similarity) / 3.0F
}
};
}
else {
// TODO: Create new token for exceptions
phrase = new Phrase() {
new FloatNumericPrimitiveToken() {
Value = 0.0F,
Text = String.Format("{0} {1} {2}", dividend.Text, forwardSlash.Text, divisor.Text),
Similarity = (dividend.Similarity + forwardSlash.Similarity + divisor.Similarity) / 3.0F
}
};
}
return phrase;
}
示例2: putObjectString
// Map a given object path to a value in the Trie.
public bool putObjectString(Word[] characters, Phrase phrase)
{
Node p = root;
for (int n=0; n < characters.Length; n++)
{
Word character = characters[n];
// Try to get a pointer to the next node
Node child = p.getChildNode(character);
// If there is no next node, then make it.
if (child == null)
{
if (n == characters.Length - 1)
{
p.setChildNode(character, new Node(character, phrase));
return false; // False: it wasn't here already.
}
else
{
p.setChildNode(character, new Node(character));
}
}
else
{
// Move the pointer down the Trie.
p = child;
}
}
// If we get to this point, then the final node wasn't new (or we would have returned).
// So, we just need to overwrite the value in that location.
p.addPhrase(phrase);
return true; // true because we overwrote what was there.
}
示例3: GetPhrases
public static List<Phrase> GetPhrases(this Tree root, Rhetorica.Sentence sentence = null, string ignore = "", string punctuation = null, AnalyzerOptions options = AnalyzerOptions.None)
{
var phrases = new List<Phrase>();
for (java.util.Iterator i = root.iterator(); i.hasNext(); ) {
Tree tree = (Tree)i.next();
if (tree.isPhrasal()) {
java.util.List children = tree.getChildrenAsList();
if (children.size() == 1 && ((Tree)children.get(0)).isPhrasal())
continue;
var current = new Phrase(tree.GetTokens(root, sentence, ignore, punctuation, options));
// If current node matches previous node but for punctuation omission, replace previous with current:
bool omitFalseDuplicatePhrases = options.HasFlag(AnalyzerOptions.OmitFalseDuplicatePhrases);
if (omitFalseDuplicatePhrases) {
if (phrases.Count > 0) {
Phrase previous = phrases.Last();
if (previous.EqualExceptPunctuationOmission(current)) {
phrases[phrases.Count - 1] = current;
continue;
}
}
}
if (current.Count == 0)
continue;
phrases.Add(current);
}
}
return phrases;
}
示例4: GetTextPhrase
protected static Phrase GetTextPhrase(string text, bool isBold)
{
string fontName = isBold ? FontFactory.HELVETICA_BOLD : FontFactory.HELVETICA;
Phrase ph = new Phrase(text, FontFactory.GetFont(fontName, 10, new Color(51, 51, 51)));
return ph;
}
示例5: GeneratePdfElement
public override iTextSharp.text.IElement GeneratePdfElement()
{
SignaturePanelStyle style = (Manifest != null) ? Manifest.Styles.GetMergedFromConfiguration(Style) : Style;
Phrase phrase = new Phrase();
Chunk signature = new Chunk(Signature);
signature.Style.Font.Apply(style.Font);
phrase.Content.Add(signature);
phrase.Content.Add(new NewLine());
Separator separator = new Separator();
separator.Style.BorderColor = style.BorderColor;
separator.Style.Width = style.BorderWidth;
phrase.Content.Add(separator);
GenericIdentity identity = new GenericIdentity(User);
AD.ActiveDirectory activeDirectory = new AD.ActiveDirectory();
UserDescriptor adUser = activeDirectory.GetUser(identity.GetUserName());
string fullName = adUser.DisplayName;
phrase.Content.Add(new NewLine());
phrase.Content.Add(new Chunk(String.Format("{0} ({1:MMMM dd, yyyy})", fullName, Date)));
PdfPanel panel = new PdfPanel(phrase);
panel.Style.BackgroundColor = style.BackgroundColor;
panel.Style.BorderColor = style.BorderColor;
panel.Style.Padding = style.Padding;
panel.Style.BorderWidth = style.BorderWidth;
panel.Style.Width = style.Width;
return panel.GeneratePdfElement();
}
示例6: InvokeMethod
public OperationResult<Message> InvokeMethod(Phrase phrase)
{
var res = new OperationResult<Message>();
var msg = new Message();
try
{
object mres = phrase.Method.Invoke("dummy", phrase.Params != null? phrase.Params.ToArray():null);
var mStream = new MemoryStream();
var formatter = new BinaryFormatter();
formatter.Serialize(mStream, mres);
mStream.Close();
//var marshall = new XmlSerializer(mres.GetType());
//var mStream = new MemoryStream();
//marshall.Serialize(mStream, mres);
using (var reader = new StreamReader(mStream))
{
msg.Value = reader.ReadToEnd();
}
}
catch (Exception ex)
{
res.HasError = true;
res.Message = ex.Message;
}
res.Result = msg;
return res;
}
示例7: 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;
}
示例8: ExportPDF
public static bool ExportPDF(string path)
{
try
{
// string path = "D:\\RebateForm" + confirmDetailsRow.ConfirmationID + ".pdf"; //Server.MapPath(ConfigurationManager.AppSettings["ExportPDF"] + misc.RandomString(6, true) + ".pdf");
Document document = new Document(PageSize.A4, 3, 3, 10, 10);
PdfWriter.GetInstance(document, new FileStream(path, FileMode.Create));
Phrase ph = new Phrase("All Information Deemed Accurate but not Warranted\n EQUAL HOUSING OPPERTUNITY", FontFactory.GetFont(FontFactory.HELVETICA, 10, new Color(51, 51, 51)));
HeaderFooter footer = new HeaderFooter(ph, false);
footer.Border = 0;
footer.Alignment = Element.ALIGN_CENTER;
document.Footer = footer;
document.Open();
iTextSharp.text.Table tblMain = new iTextSharp.text.Table(2);
tblMain.Border = 0;
tblMain.DefaultCellBorder = 0;
tblMain.Cellpadding = 2;
SetTitle(confirmDetailsRow, tblMain);
SetContactInfo(confirmDetailsRow, tblMain);
document.Add(tblMain);
document.Close();
return true;
}
catch (Exception)
{
//return false;
throw;
}
}
示例9: SetUpEach
public void SetUpEach()
{
db = new InMemoryDatabase ();
phrase1 = new Phrase ("Das Restaurant", "Ресторан", "audio/lesson1/00_Das_Restaurant.mp3");
phrase2 = new Phrase ("Ich bin sehr mude", "Я очень устал,", "audio/lesson1/01_Ich_bin_sehr_mude.mp3");
phrase3 = new Phrase ("1", "2", "3");
}
示例10: GameLoop
public static void GameLoop()
{
int exactMatch = 0;
int partialMatch = 0;
int hint = 1;
bool gameOver = false;
string guessString;
Phrase actual = new Phrase();
while (!gameOver)
{
Console.Write("Enter your guess: ");
guessString = Console.ReadLine();
if (guessString == "hint")
{
string padding = new string('-', Phrase.PhraseSize - hint);
Console.WriteLine("{0}{1}", actual.Value.Substring(0, hint), padding);
// begin -- for debugging only
Console.WriteLine("{0} G x {1}", actual.Value, actual.Count.G);
Console.WriteLine("{0} A x {1}", actual.Value, actual.Count.A);
Console.WriteLine("{0} T x {1}", actual.Value, actual.Count.T);
Console.WriteLine("{0} C x {1}", actual.Value, actual.Count.C);
// end -- for debugging only
if (hint < Phrase.PhraseSize)
{
hint++;
}
else
{
Console.WriteLine("No more hints! Game Over.");
gameOver = true;
}
}
else
{
Phrase guess = new Phrase(guessString);
if (!actual.Compare(guess, out exactMatch, out partialMatch))
{
Console.WriteLine("You have {0} exact and {1} partial matches. Try again.", exactMatch, partialMatch);
}
else
{
Console.WriteLine("Congratulations! You Win!");
gameOver = true;
}
}
}
}
示例11: addPhraseAndDeleteExistingPhrases
public bool addPhraseAndDeleteExistingPhrases(Phrase phrase)
{
// Get the node where the phrase belongs
bool created;
Trie<ProseObject, List<Phrase>>.Node phraseNode = patternTrie.getOrCreateNodeAtObjectPath(phrase.getPattern(), out created);
// Make this phrase the only one at the node.
phraseNode.setValue(new List<Phrase>(1));
phraseNode.Value.Add(phrase);
return created;
}
示例12: 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;
}
示例13: addPhrase
public bool addPhrase(Phrase phrase)
{
// Get the node where the phrase belongs
bool created;
Trie<ProseObject, List<Phrase>>.Node phraseNode = patternTrie.getOrCreateNodeAtObjectPath(phrase.getPattern(), out created);
// Add the phrase to the node
if (phraseNode.Value == null) // If we have to make a place in the node to put our phrase...
phraseNode.setValue(new List<Phrase>());
phraseNode.Value.Add(phrase);
return created;
}
示例14: Parse
public new static Phrase Parse(IFuzzyState state, Phrase phrase) {
List<SelfReflectionThingObjectToken> createdTokens = null;
TokenReflection.CreateDescendants(state, phrase, out createdTokens);
if (createdTokens != null && createdTokens.Count > 0) {
foreach (SelfReflectionThingObjectToken self in createdTokens) {
state.ParseSelfReflectionThing(state, self);
}
}
return phrase;
}
示例15: PhrasesEqualityTest
public void PhrasesEqualityTest()
{
Phrase p1 = new Phrase ("1", "2", "3");
Phrase p2 = new Phrase ("1", "2", "3");
Phrase p3 = new Phrase ("1", "2", "-");
Phrase p4 = new Phrase ("1", "-", "3");
Phrase p5 = new Phrase ("-", "2", "3");
Assert.IsTrue (p1.Equals (p2));
Assert.IsFalse (p1.Equals (p3));
Assert.IsFalse (p1.Equals (p4));
Assert.IsFalse (p1.Equals (p5));
}