本文整理汇总了C#中Word类的典型用法代码示例。如果您正苦于以下问题:C# Word类的具体用法?C# Word怎么用?C# Word使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Word类属于命名空间,在下文中一共展示了Word类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetHiddenWord
public void TestGetHiddenWord()
{
Word word = new Word("test");
string hiddenWord = word.GetHiddenWord;
Assert.AreEqual(hiddenWord, "_ _ _ _");
}
示例2: Conjugation
public Conjugation(Word verb, FirstTense firstTense, SecondTense secondTense, Person person)
{
this.verb = verb;
FirstTense = firstTense;
SecondTense = secondTense;
Person = person;
}
示例3: Print
public virtual string Print(Word word)
{
_counter.Increment();
if (_counter.Value > 1)
return word.Value + " " + _counter.Value + " times!";
return word.Value;
}
示例4: DrawWord
private static void DrawWord(Graphics grph, Word word)
{
foreach (Character ch in word.CharList)
DrawChar(grph, ch);
word.Draw(grph);
}
示例5: PhonologicalRuleNotUnapplied
public void PhonologicalRuleNotUnapplied(IPhonologicalRule rule, int subruleIndex, Word input)
{
((XElement) input.CurrentTrace).Add(new XElement("PhonologicalRuleAnalysisTrace",
CreateHCRuleElement("PhonologicalRule", rule),
CreateWordElement("Input", input, true),
CreateWordElement("Output", input, true)));
}
示例6: Add
public void Add(Word verb)
{
if (!verb.IsTypeOf(typeof(VerbType)))
{
throw new Exception(verb + " is not verb!");
}
foreach (WordType type in verb.types)
{
if (type is VerbType)
{
VerbType tv = (type as VerbType);
tv.table = this;
string tense = (tv.tense != null ? tv.tense : "");
Person person = (tv.person != null ? tv.person : new Person(0, 0, "", "", ""));
if (!this.table.ContainsKey(tv.mood)) this.table.Add(tv.mood, new Dictionary<string, Dictionary<Person, Word>>());
if (!this.table[tv.mood].ContainsKey(tense)) this.table[tv.mood].Add(tense, new Dictionary<Person, Word>());
this.table[tv.mood][tense].Add(person, verb);
}
}
}
示例7: GetChars
/// <summary>
/// Analyses type of last char (volve or consonant) and removes all chars of same type.
/// This creates <volve>,<consonant>,<volve>,<consonant>,... password.
/// </summary>
/// <returns type="System.Char[]">Array of chars.</returns>
public override char[] GetChars(Generator generator, Word password, char[] charsList)
{
ValidateInput(generator, password, charsList);
if (charsList.Length == 0) return charsList;
// Keep only proper chars (volves and consonants).
var chars = charsList.Intersect(charsets.Chars["Letters"]);
// If password already contains some chars then...
if (password.Chars.Length > 0)
{
// If last character is volve then...
if (charsets.Chars["Volves"].Contains(password.Chars.Last()))
{
// Keep only consonants.
chars = chars.Intersect(charsets.Chars["Consonants"]);
}
else
{
// Keep only volves.
chars = chars.Intersect(charsets.Chars["Volves"]);
}
}
charsList = chars.ToArray();
ValidateOutput(generator, password, charsList);
return charsList;
}
示例8: GetChars
/// <summary>
/// Analyses last char of password and removes all chars which are located on same phone key.
/// </summary>
/// <returns type="System.Char[]">Array of chars.</returns>
public override char[] GetChars(Generator generator, Word password, char[] charsList)
{
ValidateInput(generator, password, charsList);
if (charsList.Length == 0) return charsList;
// Keep only letters and numbers.
var chars = charsList.Intersect(charsets.Chars["Letnums"]);
// Limit if this is second+ letter only.
if (password.Chars.Length > 0)
{
// Get last char.
var lastChar = password.Chars.Last();
// Route thru GSM Phone keys.
for (int i = 0; i == 9; i++)
{
char[] keys = charsets.Chars["PhoneKey" + i];
// If current key contains last char of password then...
if (keys.Contains(lastChar))
{
// Remove all chars located on same key.
chars = chars.Intersect(keys);
break;
}
}
}
charsList = chars.ToArray();
ValidateOutput(generator, password, charsList);
return charsList;
}
示例9: Load
public new void Load(string card)
{
this.Name = card.Substring(0, 4);
string localNUPU = card.Substring(7, 3);
this.NUPU = Convert.ToInt32(localNUPU);
try
{
Word newWord;
for (int i = 10; i <= card.Length - 1; i += 5)
{
if (i == 10)
{
newWord = new Word { Name = "Delta-s = change in wing area(m2)", Position = EpplerCommon.WordPosition.F1, Format = EpplerCommon.WordFormat.F5p2, Value = Convert.ToSingle(card.Substring(i, 5)) };
words.Add(newWord);
}
else if (i == 15)
{
newWord = new Word { Name = "Delta-w = change in aircraft mass(kg)", Position = EpplerCommon.WordPosition.F2, Format = EpplerCommon.WordFormat.F5p2, Value = Convert.ToSingle(card.Substring(i, 5)) };
words.Add(newWord);
}
else if (i == 20)
{
newWord = new Word { Name = "Delta-Ap = change in parasite-drag area(m2)", Position = EpplerCommon.WordPosition.F3, Format = EpplerCommon.WordFormat.F5p2, Value = Convert.ToSingle(card.Substring(i, 5)) };
words.Add(newWord);
}
}
}
catch (Exception ex)
{
//TODO: implement message passing
//MessageBox.show(ex.Message);
}
}
示例10: IsApplicable
public override bool IsApplicable(Word input)
{
if (!_subrule.RequiredSyntacticFeatureStruct.IsUnifiable(input.SyntacticFeatureStruct))
{
if (input.CurrentRuleResults != null)
input.CurrentRuleResults[_index] = new Tuple<FailureReason, object>(FailureReason.RequiredSyntacticFeatureStruct, _subrule.RequiredSyntacticFeatureStruct);
return false;
}
MprFeatureGroup group;
if (_subrule.RequiredMprFeatures.Count > 0 && !_subrule.RequiredMprFeatures.IsMatchRequired(input.MprFeatures, out group))
{
if (input.CurrentRuleResults != null)
input.CurrentRuleResults[_index] = new Tuple<FailureReason, object>(FailureReason.RequiredMprFeatures, group);
return false;
}
if (_subrule.ExcludedMprFeatures.Count > 0 && !_subrule.ExcludedMprFeatures.IsMatchExcluded(input.MprFeatures, out group))
{
if (input.CurrentRuleResults != null)
input.CurrentRuleResults[_index] = new Tuple<FailureReason, object>(FailureReason.ExcludedMprFeatures, group);
return false;
}
return true;
}
示例11: LoadWords
public void LoadWords(Word[] words)
{
Array.Sort(words);
HashTable = new Dictionary<string, List<string>>(words.Length);
foreach (var word in words)
{
for (var i = 1; i <= word.Text.Length; i++)
{
var prefix = word.Text.Substring(0, i);
if (HashTable.ContainsKey(prefix))
{
if (HashTable[prefix].Count < 10)
{
HashTable[prefix].Add(word.Text);
}
}
else
{
HashTable[prefix] = new List<string> { word.Text };
}
}
}
}
示例12: AddFromTranslator
public ActionResult AddFromTranslator(string wordText, string translationsConcated)
{
try
{
var activeDict = _authService.CurrentAccount.ActiveDictionary;
var translations = translationsConcated.Split(';');
string firstTranslation = translations.First();
var newWord = new Word { Original = wordText, InsertedOn = DateTime.Now };
try
{
var pronounceFile = _translationService.GetPronounceAudioFile(wordText, activeDict.From, "mp3", String.Empty);
newWord.PronounceAudioFile = pronounceFile;
}
catch (TranslatorException)
{
}
activeDict.Words.Add(newWord);
newWord.Translations = translations.Select(t => new Translation { Value = t }).ToArray();
_wordRepository.SaveChanges();
return RedirectToAction("List", new { dictionaryId = activeDict.ID });
}
catch (Exception ex)
{
LoggingService.Instance.Log.Fatal(String.Format("A fatal error has occurred while adding a new word using an external translator service. The new word is {0}. The error is {1}", wordText, ex));
return RedirectToAction("Error", "Home");
}
}
示例13: Start
void Start()
{
NextSentence();
Word[] words = new Word[tests.WordBank.Values.Count];
int j = 0;
foreach (Word w in tests.WordBank.Values) {
words[j] = w;
j++;
}
// scramble the word order
int num = words.Length;
// decide a random order to add nouns
int[] indices = new int[num];
for (int i = 0; i < num; ++i) indices[i] = i;
for (int i = 0; i < num - 1; ++i)
{
int swp = Random.Range(i, num);
int tmp = indices[swp];
indices[swp] = indices[i];
indices[i] = tmp;
}
// add nouns
for (int i = 0; i < num; ++i)
{
CreateNoun(words[indices[i]]);
}
}
示例14: TestGetWord
public void TestGetWord()
{
Word word = new Word("test");
string originalWord = word.GetWord;
Assert.AreEqual(originalWord, "test");
}
示例15: StringToWords
private Word[] StringToWords(string s)
{
if (s == null)
{
return null;
}
int wordCount = s.Length / 4;
Word[] words = new Word[wordCount];
for (int i = 0; i < wordCount; i++)
{
words[i] = new Word(s.Substring(i * 4, 4));
}
string remaining = s.Substring(s.Length - s.Length % 4);
if (remaining.Length > 0)
{
Word[] allWords = new Word[wordCount + 1];
words.CopyTo(allWords, 0);
allWords[allWords.Length - 1] = new Word(remaining);
return allWords;
}
else
{
return words;
}
}