/// <summary> /// Classify multiple phrases. Returns label information for multiple phrases. The status must be `Available` before you can use the classifier to classify text. Note that classifying Japanese texts is a beta feature. /// </summary> /// <param name="classifierId">Classifier ID to use.</param> /// <param name="body">Phrase to classify. The maximum length of the text phrase is 1024 characters. You can submit up to 30 text phrases in a request.</param> /// <param name="customData">Custom data object to pass data including custom request headers.</param> /// <returns><see cref="ClassificationCollection" />ClassificationCollection</returns> public ClassificationCollection ClassifyCollection(string classifierId, ClassifyCollectionInput body, Dictionary <string, object> customData = null) { if (string.IsNullOrEmpty(classifierId)) { throw new ArgumentNullException(nameof(classifierId)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } ClassificationCollection result = null; try { var request = this.Client.WithAuthentication(this.UserName, this.Password) .PostAsync($"{this.Endpoint}/v1/classifiers/{classifierId}/classify_collection"); request.WithBody <ClassifyCollectionInput>(body); if (customData != null) { request.WithCustomData(customData); } result = request.As <ClassificationCollection>().Result; if (result == null) { result = new ClassificationCollection(); } result.CustomData = request.CustomData; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
public void RefreshDisplay() { _lookup = Classification.CollectAll(); _viewModel = new ClassificationViewModel { Collection = Classification.CollectAll() }; DataContext = _viewModel; }
internal CostItem(IIfcCostItem item, bool init) : base(item, init) { Children = new CostChildrenCollection(this, init); ClassificationItems = new ClassificationCollection(Entity, init); Quantities = new QuantityCollection(this); UnitValues = new ValuesCollection(this); AssociatedElements = new AssociatedElementsCollection(this, init); }
public void ClassificationsTest() { TargetGroup target = new TargetGroup(); ClassificationCollection expected = new ClassificationCollection(); target.Classifications = expected; ClassificationCollection actual = target.Classifications; Assert.AreEqual(expected, actual); }
/// <summary> /// /// </summary> static private void CheckIsValidAllTargetGroups( Microsoft.UpdateServices.Administration.IUpdateServer server, AllTargetGroups allTargetGroups, System.String runSetName ) { Rule allClassifications = allTargetGroups.AllClassifications; ClassificationCollection classifications = allTargetGroups.Classifications; CheckIsValidClassifications(server, allClassifications, classifications, runSetName, null); }
/* * static void DoRunSetClassifications( * Microsoft.UpdateServices.Administration.IUpdateServer server, * Microsoft.UpdateServices.Administration.IComputerTargetGroup ctg, * bool isTest, * System.Collections.Generic.List<Microsoft.UpdateServices.Administration.IComputerTargetGroup> alreadyProcessed * ) * { * //Model.ClassificationCollection classifications, * Microsoft.UpdateServices.Administration.UpdateClassificationCollection classifications * =server.GetUpdateClassifications(); * foreach (Model.Classification classification in classifications) * { * DoRunSetClassification(server, ctg, classification, isTest, alreadyProcessed); * } * } * */ /// <summary> /// The do run set classifications. /// </summary> /// <param name="server"> /// Object representing the WSUS server /// </param> /// <param name="computerTargetGroup"> /// The target group to check /// </param> /// <param name="classifications"> /// Collection of Classifications to process /// </param> /// <param name="isTest"> /// Whether we are in test mode /// </param> /// <param name="alreadyProcessed"> /// List of target groups that have already been processed /// </param> private static void DoRunSetClassifications( IUpdateServer server, IComputerTargetGroup computerTargetGroup, ClassificationCollection classifications, bool isTest, List <IComputerTargetGroup> alreadyProcessed) { foreach (Classification classification in classifications) { DoRunSetClassification(server, computerTargetGroup, classification, isTest, alreadyProcessed); } }
public string FindClassificationByPath(string path) { string result; var searchExpr = new SearchExpression("NamePath=" + path); var classificationCollection = new ClassificationCollection(application); classificationCollection.Load(searchExpr); if (classificationCollection.Count > 0) result = classificationCollection[0].Name; else result = "Not found"; return result; }
internal static ClassificationCollection CollectAll() { var dataTable = DatabaseController.ExecuteSelectQuery("SELECT * FROM " + TABLE_NAME); var collection = new ClassificationCollection(); foreach (DataRow dataRow in dataTable.Rows) { var item = new Classification(); item.SetPropertiesFromDataRow(dataRow); collection.Add(item); } return(collection); }
internal Project(IIfcProject project, bool init) : base(project) { CostSchedules = new CostSchedulesCollection(this, init); ClassificationItems = new ClassificationCollection(Entity, init); if (!init) { return; } var rel = project.IsDecomposedBy.FirstOrDefault(r => r.RelatedObjects.Any(o => o is IIfcSite)); _site = rel?.RelatedObjects.OfType <IIfcSite>().FirstOrDefault(); }
/// <summary> /// Classify multiple phrases. /// /// Returns label information for multiple phrases. The status must be `Available` before you can use the /// classifier to classify text. /// /// Note that classifying Japanese texts is a beta feature. /// </summary> /// <param name="classifierId">Classifier ID to use.</param> /// <param name="body">Phrase to classify. You can submit up to 30 text phrases in a request.</param> /// <param name="customData">Custom data object to pass data including custom request headers.</param> /// <returns><see cref="ClassificationCollection" />ClassificationCollection</returns> public ClassificationCollection ClassifyCollection(string classifierId, ClassifyCollectionInput body, Dictionary <string, object> customData = null) { if (string.IsNullOrEmpty(classifierId)) { throw new ArgumentNullException(nameof(classifierId)); } if (body == null) { throw new ArgumentNullException(nameof(body)); } ClassificationCollection result = null; try { IClient client = this.Client; if (_tokenManager != null) { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } if (_tokenManager == null) { client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/classifiers/{classifierId}/classify_collection"); restRequest.WithBody <ClassifyCollectionInput>(body); if (customData != null) { restRequest.WithCustomData(customData); } restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=natural_language_classifier;service_version=v1;operation_id=ClassifyCollection"); result = restRequest.As <ClassificationCollection>().Result; if (result == null) { result = new ClassificationCollection(); } result.CustomData = restRequest.CustomData; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
static void Main(string[] args) { Application app = new Application(); LogOnStatus status = app.LogOn("LUXDAM", "Eduard_Pasmetukhau", "P2ssw0rd!"); if (status == LogOnStatus.LoggedOn) { Console.WriteLine("Ok"); } else Console.WriteLine(status); Classification c = new Classification(app); ClassificationHelper ch = new ClassificationHelper(app); Guid? rootGuid= ch.GetId(new SearchExpression("name = 'Luxottica Content*'")); Console.WriteLine("List of classification with parent Luxottica Content"); //Console.ReadKey(); if (rootGuid != null) { ClassificationCollection classCollections = new ClassificationCollection(app); classCollections.Load(new SearchExpression(String.Format("parent = '{0}'", rootGuid))); foreach (Classification classification in classCollections) { Console.WriteLine(classification.Label + " Guid: "+classification.Id); } } Console.WriteLine(); Console.ReadKey(); Console.WriteLine("First 10 Guids of Records in classification Luxottica Content"); RecordCollection rc = new RecordCollection(app); rc.Load(new SearchExpression(String.Format("classification = '{0}'", rootGuid))); foreach (Record r in rc.Take<Record>(10)) { Console.WriteLine(r.Id); } Console.ReadKey(); }
/// <summary> /// /// </summary> static private void CheckIsValidClassifications( Microsoft.UpdateServices.Administration.IUpdateServer server, ClassificationCollection classifications, System.String runSetName, System.String groupId ) { if (classifications.Count < 1) { throw new System.Configuration.ConfigurationErrorsException( "The \"Classifications\" section in runset \"" + runSetName + "\" must have at least 1 item." ); } foreach (Classification classification in classifications) { CheckIsValidClassification(server, classification, runSetName, groupId); } }
/// <summary> /// The do run set all target groups. /// </summary> /// <param name="server"> /// </param> /// <param name="allTargetGroups"> /// </param> /// <param name="isTest"> /// </param> /// <param name="alreadyProcessed"> /// List of target groups that have already been processed /// </param> private static void DoRunSetAllTargetGroups( IUpdateServer server, AllTargetGroups allTargetGroups, bool isTest, List <IComputerTargetGroup> alreadyProcessed) { Console.Out.WriteLine("Getting root target group: "); IComputerTargetGroup rootGroup = Server.GetRootTargetGroup(server); ClassificationCollection classifications = allTargetGroups.Classifications; if (classifications.Count > 0) { DoRunSetClassifications(server, rootGroup, classifications, isTest, alreadyProcessed); } else { DoRunSetAllClassifications(server, rootGroup, isTest, allTargetGroups.AllClassifications); } }
static private void CheckIsValidClassifications( Microsoft.UpdateServices.Administration.IUpdateServer server, // ReSharper disable UnusedParameter.Local Rule allClassifications, // ReSharper restore UnusedParameter.Local ClassificationCollection classifications, System.String runSetName, System.String groupId ) { if ( classifications.Count == 0 && allClassifications.ElementInformation.IsPresent == false ) { throw new System.ArgumentException( "\"AllClassifications\" or \"Classifications\" missing from the runset \"" + runSetName + "\\AllTargetGroups\" section." ); } if ( classifications.Count > 0 && allClassifications.ElementInformation.IsPresent ) { throw new System.ArgumentException( "\"AllClassifications\" and \"Classifications\" are both specified in runset \"" + runSetName + "\". You must specify one or the other." ); } if (classifications.Count > 0) { CheckIsValidClassifications(server, classifications, runSetName, groupId); } //else //{ //nothing to do //AllClassifications is set to require all settings //and will fail before this point //} }
public IEnumerator TestClassifyCollection() { Log.Debug("NaturalLanguageClassifierServiceV1IntegrationTests", "Attempting to ClassifyCollection..."); ClassificationCollection classifyCollectionResponse = null; List <ClassifyInput> collection = new List <ClassifyInput>() { new ClassifyInput() { Text = textToClassify0 }, new ClassifyInput() { Text = textToClassify1 } }; service.ClassifyCollection( callback: (DetailedResponse <ClassificationCollection> response, IBMError error) => { Log.Debug("NaturalLanguageClassifierServiceV1IntegrationTests", "ClassifyCollection result: {0}", response.Response); classifyCollectionResponse = response.Result; Assert.IsNotNull(classifyCollectionResponse); Assert.IsNotNull(classifyCollectionResponse.Collection); Assert.IsTrue(classifyCollectionResponse.Collection.Count > 0); Assert.IsTrue(classifyCollectionResponse.ClassifierId == classifierId); Assert.IsNull(error); }, classifierId: classifierId, collection: collection ); while (classifyCollectionResponse == null) { yield return(null); } }
/// <summary> /// /// </summary> static private void CheckIsValidTargetGroup( Microsoft.UpdateServices.Administration.IUpdateServer server, TargetGroup targetGroup, System.String runSetName ) { //make sure the guid exists try { server.GetComputerTargetGroup(targetGroup.Guid); } catch (System.Exception) { throw new System.ArgumentException( "The TargetGroup Guid \"" + targetGroup.Guid + "\" could not be found on the WSUS server. Run Set: " + runSetName ); } //check the classifications Rule allClassifications = targetGroup.AllClassifications; ClassificationCollection classifications = targetGroup.Classifications; CheckIsValidClassifications(server, allClassifications, classifications, runSetName, targetGroup.Guid.ToString()); }
public List<string> FindClassificationByPathAndDate(string path, DateTime date) { //TO DO here subclassification, not root var result = new List<string>(); string id; var searchExpr = new SearchExpression("NamePath=" + path); var classificationCollection = new ClassificationCollection(application); classificationCollection.Load(searchExpr); if (classificationCollection.Count > 0) id = classificationCollection[0].Id.ToString(); else throw new Exception("Not found"); searchExpr = new SearchExpression("Root=" + id + " AND CreatedOn > " + date.Month + '/' + date.Day + '/' + date.Year); classificationCollection = new ClassificationCollection(application); classificationCollection.Load(searchExpr); foreach (Classification classification in classificationCollection) { result.Add(classification.Name); } return result; }
private void OnClassifyCollection(ClassificationCollection result, Dictionary <string, object> customData) { Log.Debug("ExampleNaturalLanguageClassifier.OnClassifyCollection()", "Natural Language Classifier - Classify Collection Response: {0}", customData["json"].ToString()); _classifyCollectionTested = true; }
/* static void DoRunSetClassifications( Microsoft.UpdateServices.Administration.IUpdateServer server, Microsoft.UpdateServices.Administration.IComputerTargetGroup ctg, bool isTest, System.Collections.Generic.List<Microsoft.UpdateServices.Administration.IComputerTargetGroup> alreadyProcessed ) { //Model.ClassificationCollection classifications, Microsoft.UpdateServices.Administration.UpdateClassificationCollection classifications =server.GetUpdateClassifications(); foreach (Model.Classification classification in classifications) { DoRunSetClassification(server, ctg, classification, isTest, alreadyProcessed); } } * */ /// <summary> /// The do run set classifications. /// </summary> /// <param name="server"> /// Object representing the WSUS server /// </param> /// <param name="computerTargetGroup"> /// The target group to check /// </param> /// <param name="classifications"> /// Collection of Classifications to process /// </param> /// <param name="isTest"> /// Whether we are in test mode /// </param> /// <param name="alreadyProcessed"> /// List of target groups that have already been processed /// </param> private static void DoRunSetClassifications( IUpdateServer server, IComputerTargetGroup computerTargetGroup, ClassificationCollection classifications, bool isTest, List<IComputerTargetGroup> alreadyProcessed) { foreach (Classification classification in classifications) { DoRunSetClassification(server, computerTargetGroup, classification, isTest, alreadyProcessed); } }
internal CostSchedule(IIfcCostSchedule schedule, bool init) : base(schedule, init) { CostItems = new RootItemsCollection(this, init); Actors = new ActorsCollection(this, init); ClassificationItems = new ClassificationCollection(Entity, init); }
public void TestClassifiers_Success() { var listClassifiersResult = ListClassifiers(); string classifierId = null; if (listClassifiersResult.Classifiers.Count > 0) { classifierId = listClassifiersResult.Classifiers[0].ClassifierId; } Classification classifyResult = null; if (!string.IsNullOrEmpty(classifierId)) { ClassifyInput classifyInput = new ClassifyInput { Text = _textToClassify1 }; classifyResult = Classify(classifierId, classifyInput); } ClassificationCollection classifyCollectionResult = null; if (!string.IsNullOrEmpty(classifierId)) { ClassifyCollectionInput classifyCollectionInput = new ClassifyCollectionInput { Collection = new List <ClassifyInput>() { new ClassifyInput() { Text = _textToClassify0 }, new ClassifyInput() { Text = _textToClassify1 } } }; classifyCollectionResult = ClassifyCollection(classifierId, classifyCollectionInput); } Classifier createClassifierResult = null; using (FileStream classifierData = File.OpenRead(_classifierDataFilePath), metadata = File.OpenRead(_metadataDataFilePath)) { createClassifierResult = _service.CreateClassifier(metadata, classifierData); } var createdClassifierId = createClassifierResult.ClassifierId; var getClassifierResult = GetClassifier(createdClassifierId); if (!string.IsNullOrEmpty(classifierId) && !string.IsNullOrEmpty(createdClassifierId)) { DeleteClassifier(createdClassifierId); } if (!string.IsNullOrEmpty(classifierId)) { Assert.IsNotNull(classifyResult); Assert.IsNotNull(classifyCollectionResult); } Assert.IsNotNull(getClassifierResult); Assert.IsTrue(createdClassifierId == getClassifierResult.ClassifierId); Assert.IsNotNull(createClassifierResult); Assert.IsNotNull(listClassifiersResult); }
public void ClassificationCollectionConstructorTest() { ClassificationCollection target = new ClassificationCollection(); }
private static void CheckIsValidClassifications( Microsoft.UpdateServices.Administration.IUpdateServer server, // ReSharper disable UnusedParameter.Local Rule allClassifications, // ReSharper restore UnusedParameter.Local ClassificationCollection classifications, System.String runSetName, System.String groupId ) { if ( classifications.Count == 0 && allClassifications.ElementInformation.IsPresent == false ) { throw new System.ArgumentException( "\"AllClassifications\" or \"Classifications\" missing from the runset \"" + runSetName + "\\AllTargetGroups\" section." ); } if ( classifications.Count > 0 && allClassifications.ElementInformation.IsPresent ) { throw new System.ArgumentException( "\"AllClassifications\" and \"Classifications\" are both specified in runset \"" + runSetName + "\". You must specify one or the other." ); } if (classifications.Count > 0) { CheckIsValidClassifications(server, classifications, runSetName, groupId); } //else //{ //nothing to do //AllClassifications is set to require all settings //and will fail before this point //} }
/// <summary> /// /// </summary> private static void CheckIsValidClassifications( Microsoft.UpdateServices.Administration.IUpdateServer server, ClassificationCollection classifications, System.String runSetName, System.String groupId ) { if (classifications.Count < 1) { throw new System.Configuration.ConfigurationErrorsException( "The \"Classifications\" section in runset \"" + runSetName + "\" must have at least 1 item." ); } foreach (Classification classification in classifications) { CheckIsValidClassification(server, classification, runSetName, groupId); } }
public void ItemTest() { ClassificationCollection target = new ClassificationCollection(); int index = 0; Classification expected = new Classification(); target.Add(expected); Classification actual = target[index]; Assert.AreEqual(expected, actual); }