public void TestUriRef() { IDictionary <String, String> prefixMap = QueryUtils.ParsePrefixes(PREFIXES); WhereClause where = QueryUtils.ParseWhere( "qm:testCase=<http://example.org/tests/24>", prefixMap); IList <SimpleTerm> children = where.Children; Assert.AreEqual(1, children.Count, "Where clause should only have one term"); SimpleTerm simpleTerm = children[0]; PName prop = simpleTerm.Property; Assert.AreEqual(prop.ns + prop.local, "http://qm.example.com/ns/testCase"); Assert.IsTrue(simpleTerm is ComparisonTerm); ComparisonTerm comparison = (ComparisonTerm)simpleTerm; Assert.AreEqual(comparison.Operator, Operator.EQUALS); IValue v = comparison.Operand; Assert.IsTrue(v is IUriRefValue); IUriRefValue uriRef = (IUriRefValue)v; Assert.AreEqual("http://example.org/tests/24", uriRef.Value); }
private void FillMatrixByWord(SimpleTerm term, int i) { List <int> indexesOfLetters = new List <int>(); for (int ind = 0; ind < term.Word.Length; ind++) { if (char.ToLower(term.Word[ind]) == char.ToLower(_mainWord.Word[i - 1])) { indexesOfLetters.Add(ind); } } int index = -1; if (indexesOfLetters.Count > 0) { index = indexesOfLetters[GetRandom(indexesOfLetters.Count)]; } if (index >= 0) { int length = term.Word.Length; for (int k = 0; k < length; k++) { _preparingMatrix[i - 1, k + MainWordHorizontalIndex - index] = new LetterFromWord(term.Word[k], term); } } }
public MainWindow(Serializer ser) { Serializer = ser; Serializer.DeleteSimilarTerms(); Serializer.SortList(); InitializeComponent(); _editedTerm = new SimpleTerm("", ""); }
private bool SomeDescriptionWordIsKey(SimpleTerm term) { foreach (var word in term.DescriptionWordsAndSplittersList) { if (word.IsKeyWord) { return(true); } } return(false); }
public override void VisitMatchingTerms(IndexReader reader, string fieldName, SimpleTerm.IMatchingTermVisitor mtv) { int prefixLength = prefix.Length; Terms terms = MultiFields.GetTerms(reader, fieldName); if (terms != null) { TermsEnum termsEnum = terms.Iterator(null); TermsEnum.SeekStatus status = termsEnum.SeekCeil(prefixRef); BytesRef text; if (status == TermsEnum.SeekStatus.FOUND) { text = prefixRef; } else if (status == TermsEnum.SeekStatus.NOT_FOUND) { text = termsEnum.Term(); } else { text = null; } while (text != null) { if (text != null && StringHelper.StartsWith(text, prefixRef)) { string textString = text.Utf8ToString(); Match matcher = pattern.Match(textString.Substring(prefixLength)); if (matcher.Success) { mtv.VisitMatchingTerm(new Term(fieldName, textString)); } } else { break; } text = termsEnum.Next(); } } }
private void ChooseRandomMainWord() { int min, max; min = (from t in List orderby t.Word.Length select t).ToList().First().Word.Length; max = (from t in List orderby t.Word.Length select t).ToList().Last().Word.Length; int dif = (max - min) / 3; if (_lvl == 1) { max = min + dif; } else if (_lvl == 2) { min = min + dif; max = max - dif; } else { min = max - dif; } List <SimpleTerm> mainWordCandidates = (from t in List where (t.Word.Length >= min) && (t.Word.Length <= max) orderby t.Word.Length select t).ToList(); while (mainWordCandidates.Count == 0) { min--; max++; mainWordCandidates = (from t in List where (t.Word.Length >= min) && (t.Word.Length <= max) orderby t.Word.Length select t).ToList(); } if (mainWordCandidates.Count > 0) { _maxLength = (from t in List orderby t.Word.Length select t).ToList().Last().Word.Length; _mainWord = mainWordCandidates[GetRandom(mainWordCandidates.Count)]; List.Remove(_mainWord); } }
private void EditBTN_Click(object sender, RoutedEventArgs e) { bool editingSuccess = false; if ((!(string.IsNullOrEmpty(TermTB.Text) || string.IsNullOrEmpty(DescriptionTB.Text)))) { if (!_editMode) { try { Serializer.TermList.Add(new SimpleTerm(TermTB.Text, DescriptionTB.Text)); if (Serializer.DeleteSimilarTerms()) { MessageBox.Show("Данный термин уже внесён в словарь!"); } else { editingSuccess = true; } } catch (Exception) { MessageBox.Show("Не удалось добавить новый термин."); } } else { var termEdited = new SimpleTerm(TermTB.Text, DescriptionTB.Text); var hasSimilar = (from t in Serializer.TermList where t.Word == termEdited.Word && t.Description == termEdited.Description select t).Count(); if (hasSimilar != 0) { MessageBox.Show("Данный термин уже внесён в словарь!"); } else { _editedTerm.Word = termEdited.Word; _editedTerm.Description = termEdited.Description; editingSuccess = true; } } } else { MessageBox.Show("Нужно заполнить поля термин и описание перед добавлением."); } if (editingSuccess) { Serializer.SortList(); Serializer.Serialize(); EditBTN.FontFamily = new FontFamily("Segoe MDL2 Assets"); EditBTN.Foreground = Brushes.MediumSeaGreen; EditBTN.FontWeight = FontWeights.Bold; EditBTN.Content = "\xE73E" + " "; EditBTN.IsEnabled = false; } else { EditBTN.FontFamily = new FontFamily("Segoe MDL2 Assets"); EditBTN.Foreground = Brushes.Red; EditBTN.FontWeight = FontWeights.Bold; EditBTN.Content = "\xE711" + " "; EditBTN.IsEnabled = false; } }
private static void DisableCheckBox(CheckBox isKey, SimpleTerm term) { isKey.IsChecked = false; isKey.IsEnabled = false; term.ReadyForFillGame = false; }
public LetterFromWord(char letter, SimpleTerm term) { Letter = letter; Term = term; }
public SimpleLambda(string parameter, SimpleTerm body) { Parameter = parameter; Body = body; }
public SimplePair(SimpleTerm left, SimpleTerm right) { Left = left; Right = right; }
public SimpleType(Polarity polarity, SimpleTerm quantifier, SimpleTerm body) { Polarity = polarity; Quantifier = quantifier; Body = body; }
public SimpleUnpack(string left, string right, SimpleTerm continuation) { Left = left; Right = right; Continuation = continuation; }
public SimpleApply(SimpleTerm argument) { Argument = argument; }