/// <summary>Main method of mention detection.</summary> /// <remarks> /// Main method of mention detection. /// Extract all NP, PRP or NE, and filter out by manually written patterns. /// </remarks> public override IList <IList <Mention> > FindMentions(Annotation doc, Dictionaries dict, Properties props) { IList <IList <Mention> > predictedMentions = new List <IList <Mention> >(); ICollection <string> neStrings = Generics.NewHashSet(); IList <ICollection <IntPair> > mentionSpanSetList = Generics.NewArrayList(); IList <ICoreMap> sentences = doc.Get(typeof(CoreAnnotations.SentencesAnnotation)); foreach (ICoreMap s in sentences) { IList <Mention> mentions = new List <Mention>(); predictedMentions.Add(mentions); ICollection <IntPair> mentionSpanSet = Generics.NewHashSet(); ICollection <IntPair> namedEntitySpanSet = Generics.NewHashSet(); ExtractPremarkedEntityMentions(s, mentions, mentionSpanSet, namedEntitySpanSet); HybridCorefMentionFinder.ExtractNamedEntityMentions(s, mentions, mentionSpanSet, namedEntitySpanSet); ExtractNPorPRPFromDependency(s, mentions, mentionSpanSet, namedEntitySpanSet); AddNamedEntityStrings(s, neStrings, namedEntitySpanSet); mentionSpanSetList.Add(mentionSpanSet); } // extractNamedEntityModifiers(sentences, mentionSpanSetList, predictedMentions, neStrings); for (int i = 0; i < sentences.Count; i++) { FindHead(sentences[i], predictedMentions[i]); } // mention selection based on document-wise info RemoveSpuriousMentions(doc, predictedMentions, dict, CorefProperties.RemoveNestedMentions(props), lang); // if this is for MD training, skip classification if (!CorefProperties.IsMentionDetectionTraining(props)) { mdClassifier.ClassifyMentions(predictedMentions, dict, props); } return(predictedMentions); }
public override Task Initialize() { var fileNames = Directory.GetFiles(_directoryPath, "*.json", SearchOption.TopDirectoryOnly); foreach (var fileName in fileNames) { var dictionary = CreateJsonLocalizationDictionary(fileName); if (Dictionaries.ContainsKey(dictionary.CultureInfo.Name)) { throw new AbpInitializationException(SourceName + " source contains more than one dictionary for the culture: " + dictionary.CultureInfo.Name); } Dictionaries[dictionary.CultureInfo.Name] = dictionary; if (fileName.EndsWith(SourceName + ".json")) { if (DefaultDictionary != null) { throw new AbpInitializationException("Only one default localization dictionary can be for source: " + SourceName); } DefaultDictionary = dictionary; } } return(Task.FromResult(true)); }
public IDictionary <TracerFormula, double> GetDistribution(double?startTime, double?endTime) { var rawResult = new Dictionary <TracerFormula, double>(); double total = 0; if (!startTime.HasValue || !endTime.HasValue) { return(rawResult); } foreach (var entry in Points) { double value = 0; for (int i = 0; i < Times.Count; i++) { if (Times[i] < startTime || Times[i] > endTime) { continue; } value += entry.Value[i]; } total += value; rawResult.Add(entry.Key, value); } if (total == 0) { return(rawResult); } return(Dictionaries.Scale(rawResult, 1 / total)); }
public void ExistingBoard() { GameBoard board = new GameBoard(new char[4, 4] { { 'y', 'o', 'x', 'f' }, { 'y', 'o', 'x', 'u' }, { 'r', 'b', 'a', 'n' }, { 'v', 'e', 'd', 'd' } }); // Load the Alphabet Alphabet alphabet = Alphabets.Load("en-us"); // Load the Dictionary Dictionary dict = Dictionaries.Load("english-words"); BoardSolution sol = BoardConstructor.Solve(alphabet, dict, board); string solboard = sol.SolvedBoard.ToString(); int words = sol.SolutionWords.Count; Assert.InRange(words, 1, int.MaxValue); Assert.Equal(24, solboard.Length); Assert.Equal(4, sol.SolvedBoard.Size); Assert.Equal("en-us", sol.AlphabetId); Assert.Equal("english-words", sol.DictionaryId); }
public override Task Initialize() { var resourceNames = _assembly.GetManifestResourceNames(); foreach (var resourceName in resourceNames) { if (resourceName.StartsWith(_rootNamespace)) { using (var stream = _assembly.GetManifestResourceStream(resourceName)) { var xmlString = Abp.Localization.Dictionaries.Utf8Helper.ReadStringFromStream(stream); var dictionary = CreateXmlLocalizationDictionary(xmlString); if (Dictionaries.ContainsKey(dictionary.CultureInfo.Name)) { throw new AbpInitializationException(SourceName + " source contains more than one dictionary for the culture: " + dictionary.CultureInfo.Name); } Dictionaries[dictionary.CultureInfo.Name] = dictionary; if (resourceName.EndsWith(SourceName + ".xml")) { if (DefaultDictionary != null) { throw new AbpInitializationException("Only one default localization dictionary can be for source: " + SourceName); } DefaultDictionary = dictionary; } } } } return(Task.FromResult(true)); }
public FilterRecordsForm() { InitializeComponent(); clbTypesOptions.DataSource = Dictionaries.GetDictionaries().Where(x => x.DictionaryTypeId == 1).ToList(); clbTypesOptions.DisplayMember = "StringValue"; clbTypesOptions.ValueMember = "EnumValue"; }
public static void TranslateForm(WinForms.Form form, string dictName, WinForms.ToolTip toolTip = null, params WinForms.ContextMenuStrip[] contextMenus) { Dict dict; if (form != null && Dictionaries.TryGetValue(dictName, out dict)) { Dictionary <string, ControlInfo> controlInfoDict = GetControlInfoDict(dict); // перевод заголовка формы ControlInfo controlInfo; if (controlInfoDict.TryGetValue("this", out controlInfo) && controlInfo.Text != null) { form.Text = controlInfo.Text; } // перевод элементов управления TranslateWinControls(form.Controls, toolTip, controlInfoDict); // перевод контекстных меню if (contextMenus != null) { TranslateWinControls(contextMenus, null, controlInfoDict); } } }
public void MergeHeaders_MergeUniqueKeys_ReturnsExpectedunion() { //given var dict1 = new Dictionary <string, object> { { "one", "1" }, { "two", "2" } }; var dict2 = new Dictionary <string, object> { { "three", "3" }, { "four", "4" } }; var dict3 = new Dictionary <string, object> { { "five", 5 }, { "six", 6 } }; //when var ret = Dictionaries.MergeHeaders(dict1, dict2, dict3); //then Assert.That(6, Is.EqualTo(ret.Count)); Assert.That(ret["one"], Is.EqualTo("1")); Assert.That(ret["two"], Is.EqualTo("2")); Assert.That(ret["three"], Is.EqualTo("3")); Assert.That(ret["four"], Is.EqualTo("4")); Assert.That(ret["five"], Is.EqualTo(5)); Assert.That(ret["six"], Is.EqualTo(6)); }
/// <exception cref="System.Exception"/> public static void DoTraining(Properties props) { SetTrainingPath(props); Dictionaries dictionaries = new Dictionaries(props); SetDataPath("train"); wordCountsFile = trainingPath + "train/word_counts.ser"; CorefProperties.SetInput(props, CorefProperties.Dataset.Train); Preprocess(props, dictionaries, true); SetDataPath("dev"); CorefProperties.SetInput(props, CorefProperties.Dataset.Dev); Preprocess(props, dictionaries, false); SetDataPath("train"); dictionaries = null; PairwiseModel classificationModel = PairwiseModel.NewBuilder(ClassificationModel, MetaFeatureExtractor.NewBuilder().Build()).Build(); PairwiseModel rankingModel = PairwiseModel.NewBuilder(RankingModel, MetaFeatureExtractor.NewBuilder().Build()).Build(); PairwiseModel anaphoricityModel = PairwiseModel.NewBuilder(AnaphoricityModel, MetaFeatureExtractor.AnaphoricityMFE()).TrainingExamples(5000000).Build(); PairwiseModelTrainer.TrainRanking(rankingModel); PairwiseModelTrainer.TrainClassification(classificationModel, false); PairwiseModelTrainer.TrainClassification(anaphoricityModel, true); SetDataPath("dev"); PairwiseModelTrainer.Test(classificationModel, predictionsName, false); PairwiseModelTrainer.Test(rankingModel, predictionsName, false); PairwiseModelTrainer.Test(anaphoricityModel, predictionsName, true); new Clusterer().DoTraining(ClusteringModelName); }
public override void Initialize(string sourceName) { var fileNames = Directory.GetFiles(_directoryPath, "*.json", SearchOption.TopDirectoryOnly); foreach (var fileName in fileNames) { var dictionary = CreateJsonLocalizationDictionary(fileName); if (Dictionaries.ContainsKey(dictionary.CultureInfo.Name)) { throw new SharePlatformInitializationException(sourceName + " 源包含多个区域性字典: " + dictionary.CultureInfo.Name); } Dictionaries[dictionary.CultureInfo.Name] = dictionary; if (fileName.EndsWith(sourceName + ".json")) { if (DefaultDictionary != null) { throw new SharePlatformInitializationException("源只能有一个默认本地化词典: " + sourceName); } DefaultDictionary = dictionary; } } }
public Form1() { InitializeComponent(); Dictionaries.LoadDictionaries(); utility.form1 = this; this.Icon = Properties.Resources.jenicon; FormBorderStyle = FormBorderStyle.FixedSingle; rom.isStandaloneCradle = true; rom.form1 = this; /* * string ENUM_TEMPLATE = "public enum ENUMNAME {\n"; * int enum_count = 10000; * * for (int i = 0; i < enum_count; i++) * { * ENUM_TEMPLATE += "NAME = "+i+",\n"; * } * * ENUM_TEMPLATE += "}"; * File.WriteAllText("ENUM_TEMPLATE.txt", ENUM_TEMPLATE);*/ }
public override void Initialize(string sourceName, ILocalizationConfiguration localizationConfiguration) { string[] fileNames = Directory.GetFiles(_directoryPath, "*.json", SearchOption.TopDirectoryOnly); foreach (string fileName in fileNames) { JsonLocalizationDictionary dictionary = CreateJsonLocalizationDictionary(fileName); string dicCultureInfoName = dictionary.CultureInfo.Name; if (Dictionaries.ContainsKey(dicCultureInfoName)) { throw new Exception(sourceName + " source contains more than one dictionary for the culture: " + dicCultureInfoName); } Dictionaries[dicCultureInfoName] = dictionary; LanguageIcon languageIcon = LocalizationConsts.LanguageIcons.Where(p => dicCultureInfoName.StartsWith(p.CountryName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); localizationConfiguration.Languages.Add( new LanguageInfo(dicCultureInfoName, dictionary.CultureInfo.NativeName, icon: languageIcon?.Icon, isDefault: CultureInfo.CurrentUICulture.Name.Equals(dicCultureInfoName))); if (!fileName.EndsWith(sourceName + ".json")) { continue; } if (DefaultDictionary != null) { throw new Exception("Only one default localization dictionary can be for source: " + sourceName); } DefaultDictionary = dictionary; } }
private void Reset() { { CurrentBrush = null; brushes.Clear(); namedBrushes.Clear(); Dictionaries.Clear(); Lists.Clear(); if (all != null) { all.Clear(); } } { Dictionary <int, Brush> pyramids = new Dictionary <int, Brush>(); Dictionary <int, Brush> prisms = new Dictionary <int, Brush>(); Dictionary <int, Brush> antiprisms = new Dictionary <int, Brush>(); Dictionary <int, Brush> cupolas = new Dictionary <int, Brush>(); Dictionary <int, Brush> rotund = new Dictionary <int, Brush>(); Dictionary <int, Brush> diminished = new Dictionary <int, Brush>(); Dictionary <int, Brush> stella = new Dictionary <int, Brush>(); //Dictionary<int, Brush> all = new Dictionary<int,Brush>(); Dictionaries["pyramid"] = pyramids; Dictionaries["prism"] = prisms; Dictionaries["antiprism"] = antiprisms; Dictionaries["cupola"] = cupolas; Dictionaries["rotund"] = rotund; Dictionaries["diminished"] = diminished; Dictionaries["stella"] = stella; Dictionaries["all"] = all; } }
/// <summary> /// Scan for all dicitionaries (default resx files, without culture identification) /// </summary> private void ScanForDefaultDictionaries() { Dictionaries.Clear(); var culturInfoList = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => c.Name.Length > 0); _resourceDirectory = SelectedProjectDirectory.GetDirectories("Resources").Single(); var resxFiles = _resourceDirectory.GetFiles("*.resx"); foreach (FileInfo resxFile in resxFiles) { if (culturInfoList.Any(ci => resxFile.Name.EndsWith(ci.Name + ".resx"))) { continue; } Dictionaries.Add(resxFile.Name.Replace(".resx", String.Empty)); } if (Dictionaries.Any()) { string lastUsedDictionary = AppRegistry.GetValue(RegistryKeys.SelectedDictionary); if (String.IsNullOrEmpty(lastUsedDictionary)) { SelectedDictionary = Dictionaries.First(); } else { SelectedDictionary = Dictionaries.First(dict => dict == lastUsedDictionary); } } }
public void ShouldReturnEntries(MultiDictionaryContext context) { // given var multiDictionary = context.Create <int, string>(); multiDictionary.Put(1, "A"); multiDictionary.Put(1, "B"); multiDictionary.Put(1, "C"); multiDictionary.Put(2, "A"); multiDictionary.PutAll(3, Lists.AsList("X", "Y", "Z")); // when var entries = multiDictionary.Entries; // then Check.That(entries).HasSize(7); Check.That(entries).Contains( Dictionaries.Entry(1, "A"), Dictionaries.Entry(1, "B"), Dictionaries.Entry(1, "C"), Dictionaries.Entry(2, "A"), Dictionaries.Entry(3, "X"), Dictionaries.Entry(3, "Y"), Dictionaries.Entry(3, "Z")); }
private static IEnumerable <ITestCaseData> ToStringTestCases() { yield return(new TestCaseData("test") .SetName("Should return string") .Returns("test")); yield return(new TestCaseData(null) .SetName("Should generate toString of null object") .Returns("null")); yield return(new TestCaseData(new List <int?> { 1, 2, null, 3 }) .SetName("Should generate toString of collection") .Returns("[1, 2, null, 3]")); yield return(new TestCaseData(Lists.EmptyList <int>()) .SetName("Should generate toString of empty collection") .Returns("[]")); yield return(new TestCaseData((object)new object[] { "A", "B", 3, 4 }) .SetName("Should generate toString of array") .Returns("[A, B, 3, 4]")); yield return(new TestCaseData(Dictionaries.Create("A", 1, "B", 2, "C", 3)) .SetName("Should generate toString of dictionary") .Returns("[(A, 1), (B, 2), (C, 3)]")); yield return(new TestCaseData(Dictionaries.Create( "A", Lists.AsList(Lists.AsList(1, 2, 3), Lists.AsList(4, 5, 6)), "B", Lists.AsList(Lists.AsList(1), Lists.AsList(2)), "C", Lists.AsList(Lists.EmptyList <int>(), null))) .SetName("Should generate toString of complex dictionary") .Returns("[(A, [[1, 2, 3], [4, 5, 6]]), (B, [[1], [2]]), (C, [[], null])]")); }
/// <summary> /// /// </summary> /// <param name="sourceName"></param> public override void Initialize(string sourceName) { var resourceNames = _assembly.GetManifestResourceNames(); foreach (var resourceName in resourceNames) { if (resourceName.StartsWith(_rootNamespace)) { using (var stream = _assembly.GetManifestResourceStream(resourceName)) { var bytes = stream.GetAllBytes(); var xmlString = Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3); //Skipping byte order mark var dictionary = CreateXmlLocalizationDictionary(xmlString); if (Dictionaries.ContainsKey(dictionary.CultureInfo.Name)) { throw new AbpInitializationException(sourceName + " source contains more than one dictionary for the culture: " + dictionary.CultureInfo.Name); } Dictionaries[dictionary.CultureInfo.Name] = dictionary; if (resourceName.EndsWith(sourceName + ".xml")) { if (DefaultDictionary != null) { throw new AbpInitializationException("Only one default localization dictionary can be for source: " + sourceName); } DefaultDictionary = dictionary; } } } } }
internal FieldSet MakeImmutable() { bool flag = false; using (IEnumerator <object> enumerator = this.fields.Values.GetEnumerator()) { while (enumerator.MoveNext()) { object current = enumerator.Current; IList <object> list = current as IList <object>; if (list != null && !list.IsReadOnly) { flag = true; break; } } } if (flag) { SortedList <IFieldDescriptorLite, object> sortedList = new SortedList <IFieldDescriptorLite, object>(); using (IEnumerator <KeyValuePair <IFieldDescriptorLite, object> > enumerator2 = this.fields.GetEnumerator()) { while (enumerator2.MoveNext()) { KeyValuePair <IFieldDescriptorLite, object> current2 = enumerator2.Current; IList <object> list2 = current2.Value as IList <object>; sortedList[current2.Key] = ((list2 == null) ? current2.Value : Lists.AsReadOnly <object>(list2)); } } this.fields = sortedList; } this.fields = Dictionaries.AsReadOnly <IFieldDescriptorLite, object>(this.fields); return(this); }
public override bool Equals(object obj) { ExtendableMessageLite <TMessage, TBuilder> other = obj as ExtendableMessageLite <TMessage, TBuilder>; return(!ReferenceEquals(null, other) && Dictionaries.Equals(extensions.AllFields, other.extensions.AllFields)); }
public override void Initialize(string sourceName) { var fileNames = Directory.GetFiles(directoryPath, "*.json", SearchOption.TopDirectoryOnly); foreach (var fileName in fileNames) { var dictionary = CreateJsonLocalizationDictionary(fileName); if (Dictionaries.ContainsKey(dictionary.CultureInfo.Name)) { throw new StudioXInitializationException(sourceName + " source contains more than one dictionary for the culture: " + dictionary.CultureInfo.Name); } Dictionaries[dictionary.CultureInfo.Name] = dictionary; if (fileName.EndsWith(sourceName + ".json")) { if (DefaultDictionary != null) { throw new StudioXInitializationException("Only one default localization dictionary can be for source: " + sourceName); } DefaultDictionary = dictionary; } } }
/// <summary> /// Gets the data from an Xrecord. /// </summary> /// <param name="dictionaryName">Name of Named Objects Dictionary</param> /// <param name="xKey">Key of Xrecord</param> /// <returns>ResultBuffer with data or Null if nothing found.</returns> /// <exception cref="Wrappers.XRecordException"/> public ResultBuffer GetXrecord(string dictionaryName, string xKey) { ResultBuffer result = null; try { if (_document != null) { _document.StartTransaction(tr => { Transaction t = tr.Transaction; using (DBDictionary nod = Dictionaries.GetNamedObjectsDictionary(dictionaryName)) { if (nod != null && nod.Contains(xKey)) { ObjectId oid = nod.GetAt(xKey); using (Xrecord xrec = t.GetObject <Xrecord>(oid, OpenMode.ForRead)) { result = xrec.Data; } } } }); } } catch (XRecordHandlerException) { throw; } catch (Exception ex) { string err_message = string.Format("Unexpected error occured while retrieving xRecord '{0}' from Named Objects Dictionary '{1}'.", xKey, dictionaryName); throw new XRecordHandlerException(dictionaryName, xKey, err_message, ex, ErrorCode.XrecordNotFound); } return(result); }
public override void Initialize(string sourceName) { var resourceNames = assembly.GetManifestResourceNames(); foreach (var resourceName in resourceNames) { if (resourceName.StartsWith(rootNamespace)) { using (var stream = assembly.GetManifestResourceStream(resourceName)) { var jsonString = Utf8Helper.ReadStringFromStream(stream); var dictionary = CreateJsonLocalizationDictionary(jsonString); if (Dictionaries.ContainsKey(dictionary.CultureInfo.Name)) { throw new StudioXInitializationException(sourceName + " source contains more than one dictionary for the culture: " + dictionary.CultureInfo.Name); } Dictionaries[dictionary.CultureInfo.Name] = dictionary; if (resourceName.EndsWith(sourceName + ".json")) { if (DefaultDictionary != null) { throw new StudioXInitializationException("Only one default localization dictionary can be for source: " + sourceName); } DefaultDictionary = dictionary; } } } } }
/// <summary>Orders the antecedents for the given mention (m1)</summary> /// <param name="antecedentSentence"/> /// <param name="mySentence"/> /// <param name="orderedMentions"/> /// <param name="orderedMentionsBySentence"/> /// <param name="m1"/> /// <param name="m1Position"/> /// <param name="corefClusters"/> /// <param name="dict"/> /// <returns>An ordering of potential antecedents depending on same/different sentence, etc.</returns> public virtual IList <Mention> GetOrderedAntecedents(int antecedentSentence, int mySentence, IList <Mention> orderedMentions, IList <IList <Mention> > orderedMentionsBySentence, Mention m1, int m1Position, IDictionary <int, CorefCluster> corefClusters , Dictionaries dict) { IList <Mention> orderedAntecedents = new List <Mention>(); // ordering antecedents if (antecedentSentence == mySentence) { // same sentence Sharpen.Collections.AddAll(orderedAntecedents, orderedMentions.SubList(0, m1Position)); if (flags.DoPronoun && m1.IsPronominal()) { // TODO orderedAntecedents = SortMentionsForPronoun(orderedAntecedents, m1); } if (dict.relativePronouns.Contains(m1.SpanToString())) { Java.Util.Collections.Reverse(orderedAntecedents); } } else { // previous sentence Sharpen.Collections.AddAll(orderedAntecedents, orderedMentionsBySentence[antecedentSentence]); } return(orderedAntecedents); }
/// <summary> /// Removes Xrecord with given key /// </summary> /// <param name="dictionaryName">Name of Objects Dictionary.</param> /// <param name="xKey">Key of Xrecord to remove.</param> /// <returns>True if succeed, false if Xrecord does not exist.</returns> public bool RemoveDocumentXrecord(string dictionaryName, string xKey) { bool result = false; string err_message = string.Empty; try { Common.UsingTransaction(_document, tr => { Transaction t = tr.Transaction; using (DBDictionary nod = Dictionaries.GetNamedObjectsDictionary(dictionaryName)) { result = RemoveXrecord(nod, dictionaryName, xKey); } }); return(result); } catch (WriteEnablerException) { throw new XRecordHandlerException(dictionaryName, xKey, "WriteEnabler countered an exception.", ErrorCode.Error); } catch (Exception ex) { err_message = string.Format("An unexpected error occured while removing Xrecord '{0}' from Named Objects Dictionary '{1}'", xKey, dictionaryName); throw new XRecordHandlerException(dictionaryName, xKey, err_message, ex); } }
public static string EncodeBytes(byte[] payload, object key, JweAlgorithm alg, JweEncryption enc, JweCompression?compression = null, IDictionary <string, object> extraHeaders = null) { if (payload == null) { throw new ArgumentNullException("payload"); } IKeyManagement item = JWT.KeyAlgorithms[alg]; IJweAlgorithm jweAlgorithm = JWT.EncAlgorithms[enc]; IDictionary <string, object> strs = new Dictionary <string, object>() { { "alg", JWT.JweAlgorithms[alg] }, { "enc", JWT.JweEncryptionMethods[enc] } }; Dictionaries.Append <string, object>(strs, extraHeaders); byte[][] numArray = item.WrapNewKey(jweAlgorithm.KeySize, key, strs); byte[] numArray1 = numArray[0]; byte[] numArray2 = numArray[1]; if (compression.HasValue) { strs["zip"] = JWT.JweCompressionMethods[compression.Value]; payload = JWT.CompressionAlgorithms[compression.Value].Compress(payload); } byte[] bytes = Encoding.UTF8.GetBytes(JWT.jsMapper.Serialize(strs)); byte[] bytes1 = Encoding.UTF8.GetBytes(Compact.Serialize(new byte[][] { bytes })); byte[][] numArray3 = jweAlgorithm.Encrypt(bytes1, payload, numArray1); return(Compact.Serialize(new byte[][] { bytes, numArray2, numArray3[0], numArray3[1], numArray3[2] })); }
public static string EncodeBytes(byte[] payload, object key, JwsAlgorithm algorithm, IDictionary <string, object> extraHeaders = null) { if (payload == null) { throw new ArgumentNullException("payload"); } if (extraHeaders == null) { extraHeaders = new Dictionary <string, object>() { { "typ", "JWT" } }; } Dictionary <string, object> strs = new Dictionary <string, object>() { { "alg", JWT.JwsAlgorithms[algorithm] } }; Dictionaries.Append <string, object>(strs, extraHeaders); byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(strs)); byte[] numArray = Encoding.UTF8.GetBytes(Compact.Serialize(new byte[][] { bytes, payload })); //byte[] numArray1 = JWT.HashAlgorithms[algorithm].Sign(numArray, key); SHA512 sha1 = SHA512.Create(); byte[] numArray1 = sha1.ComputeHash(numArray); //System.Security.Cryptography.SHA512Cng -- return(Compact.Serialize(new byte[][] { bytes, payload, numArray1 })); }
/// <summary>Generate the training features from the CoNLL input file.</summary> /// <returns>Dataset of feature vectors</returns> /// <exception cref="System.Exception"/> private static GeneralDataset <string, string> GenerateFeatureVectors(Properties props) { GeneralDataset <string, string> dataset = new Dataset <string, string>(); Dictionaries dict = new Dictionaries(props); DocumentMaker docMaker = new DocumentMaker(props, dict); Document document; while ((document = docMaker.NextDoc()) != null) { SetTokenIndices(document); IDictionary <int, CorefCluster> entities = document.goldCorefClusters; // Generate features for coreferent mentions with class label 1 foreach (CorefCluster entity in entities.Values) { foreach (Mention mention in entity.GetCorefMentions()) { // Ignore verbal mentions if (mention.headWord.Tag().StartsWith("V")) { continue; } IndexedWord head = mention.enhancedDependency.GetNodeByIndexSafe(mention.headWord.Index()); if (head == null) { continue; } List <string> feats = mention.GetSingletonFeatures(dict); dataset.Add(new BasicDatum <string, string>(feats, "1")); } } // Generate features for singletons with class label 0 List <CoreLabel> gold_heads = new List <CoreLabel>(); foreach (Mention gold_men in document.goldMentionsByID.Values) { gold_heads.Add(gold_men.headWord); } foreach (Mention predicted_men in document.predictedMentionsByID.Values) { SemanticGraph dep = predicted_men.enhancedDependency; IndexedWord head = dep.GetNodeByIndexSafe(predicted_men.headWord.Index()); if (head == null || !dep.VertexSet().Contains(head)) { continue; } // Ignore verbal mentions if (predicted_men.headWord.Tag().StartsWith("V")) { continue; } // If the mention is in the gold set, it is not a singleton and thus ignore if (gold_heads.Contains(predicted_men.headWord)) { continue; } dataset.Add(new BasicDatum <string, string>(predicted_men.GetSingletonFeatures(dict), "0")); } } dataset.SummaryStatistics(); return(dataset); }
void FiveKWords() { Dictionary dict = Dictionaries.Load("5kwords"); Assert.Equal(5000, dict.Words.Count); DictionaryLookupInfo result = DictionaryLookupInfo.BuildLookupInfo(dict); }
/// <summary> /// Makes this FieldSet immutable, and returns it for convenience. Any /// mutable repeated fields are made immutable, as well as the map itself. /// </summary> internal FieldSet MakeImmutable() { // First check if we have any repeated values bool hasRepeats = false; foreach (object value in fields.Values) { IList <object> list = value as IList <object>; if (list != null && !list.IsReadOnly) { hasRepeats = true; break; } } if (hasRepeats) { var tmp = new SortedList <IFieldDescriptorLite, object>(); foreach (KeyValuePair <IFieldDescriptorLite, object> entry in fields) { IList <object> list = entry.Value as IList <object>; tmp[entry.Key] = list == null ? entry.Value : Lists.AsReadOnly(list); } fields = tmp; } fields = Dictionaries.AsReadOnly(fields); return(this); }
public List <Dictionaries> getDictionary() { List <Dictionaries> dictionary = new List <Dictionaries>(); Dictionaries pengguna = new Dictionaries(); pengguna.Table_name = "Pengguna"; pengguna.Dictionary.Add("id_pengguna", "int(11)"); pengguna.Dictionary.Add("nama", "varchar(255)"); pengguna.Dictionary.Add("username", "varchar(255)"); pengguna.Dictionary.Add("email", "varchar(255)"); pengguna.Dictionary.Add("user_type", "varchar(255)"); pengguna.Dictionary.Add("password", "varchar(255)"); dictionary.Add(pengguna); Dictionaries kategori = new Dictionaries(); kategori.Table_name = "Kategori"; kategori.Dictionary.Add("id_kategori", "varchar(255)"); kategori.Dictionary.Add("nama_kategori", "varchar(255)"); dictionary.Add(kategori); Dictionaries detail_barang = new Dictionaries(); detail_barang.Table_name = "Detail_Barang"; detail_barang.Dictionary.Add("id_detail_barang", "int(11)"); detail_barang.Dictionary.Add("id_barang", "varchar(255)"); detail_barang.Dictionary.Add("nomor_seri_detail", "varchar(255)"); detail_barang.Dictionary.Add("status_detail", "enum('ready','pending','defaced','reserved')"); detail_barang.Dictionary.Add("keterangan_detail", "text"); dictionary.Add(detail_barang); Dictionaries spesifikasi = new Dictionaries(); spesifikasi.Table_name = "Spesifikasi"; spesifikasi.Dictionary.Add("id_spesifikasi", "int(255)"); spesifikasi.Dictionary.Add("xid_barang", "varchar(255)"); spesifikasi.Dictionary.Add("rincian_spesifikasi", "text"); dictionary.Add(spesifikasi); Dictionaries barang = new Dictionaries(); barang.Table_name = "Barang"; barang.Dictionary.Add("id_barang", "varchar(255)"); barang.Dictionary.Add("xid_kategori", "varchar(255)"); barang.Dictionary.Add("xid_pengguna", "int(11)"); barang.Dictionary.Add("nama_barang", "text"); barang.Dictionary.Add("merk_barang", "text"); barang.Dictionary.Add("harga_barang", "int(11)"); barang.Dictionary.Add("stok_barang", "int(11)"); barang.Dictionary.Add("image_barang", "int(11)"); dictionary.Add(barang); return(dictionary); }
protected void Page_Load(object sender, EventArgs e) { dictionaries = new Dictionaries(HttpContext.Current); if (!Page.IsPostBack) { dictionarySelector.DataSource = dictionaries.DictionaryNames(); dictionarySelector.DataBind(); } if (dictionarySelector.Items.Count == 0) { addPanel.Visible = false; searchPanel.Visible = false; importPanel.Visible = false; dictionarySelector.Visible = false; messageLabel.Text = "No dictionaries imported."; } else { addPanel.Visible = true; searchPanel.Visible = true; importPanel.Visible = true; } //ClearWordList(); }