/** * Sets the concepts to be used to modify this model. * <p> * Calling this method twice will result in the old list being overwritten with the contents of this list. * * @param action the action to use when modifying these concepts * @param concepts the concepts to modify on this model * @return this request-builder * @see #withConcepts(Action, List) * @see Action#MERGE * @see Action#OVERWRITE * @see Action#REMOVE */ @NotNull public ModifyModelRequest withConcepts(@NotNull Action action, @NotNull Concept... concepts) { return withConcepts(action, Arrays.asList(concepts)); }
@NotNull @Override protected ClarifaiRequest<ConceptModel> build() { if (language != null) { return new ModifyModelRequest(client, modelID).withConcepts(action, concepts).withLanguage(language); } else { return new ModifyModelRequest(client, modelID).withConcepts(action, concepts); } }
@Test public void errorsExposedToUser() { final ClarifaiResponse<ConceptModel> response = client.getDefaultModels().generalModel().modify() .withConcepts(Action.MERGE, Concept.forID("concept2")) .executeSync(); if (response.isSuccessful()) { fail("You shouldn't be able to add concepts to the built-in general model"); } logger.debug(response.getStatus().toString()); }
@Test public void addConceptsToModel() { client.modifyModel("{{model_id}}") .withConcepts(Action.MERGE, Concept.forID("dogs")) .executeSync(); // Or, if you have a ConceptModel object, you can do it in an OO fashion final ConceptModel model = client.getModelByID("{{model_id}}").executeSync().get().asConceptModel(); model.modify() .withConcepts(Action.MERGE, Concept.forID("dogs")) .executeSync(); }
@Test public void removeConceptsFromAModel() { client.modifyModel("{{model_id}}") .withConcepts(Action.REMOVE, Concept.forID("dogs")) .executeSync(); // Or, if you have a ConceptModel object, you can do it in an OO fashion final ConceptModel model = client.getModelByID("{{model_id}}").executeSync().get().asConceptModel(); model.modify() .withConcepts(Action.REMOVE, Concept.forID("dogs")) .executeSync(); }
@Retry @Test public void t14a_addConceptsToModel() { assertSuccess(client.modifyModel(getModelID()) .withConcepts(Action.MERGE, Concept.forID("outdoors23")) ); }
@Retry @Test public void testModifyModel() { final String modelID = "modifyingModel" + System.nanoTime(); assertSuccess(client.createModel(modelID).withOutputInfo( ConceptOutputInfo.forConcepts( Concept.forID("foo") ) )); assertSuccess(client.modifyModel(modelID) .withConcepts(Action.OVERWRITE, Concept.forID("bar")) ); final List<Concept> concepts = assertSuccess(client.getModelByID(modelID)).asConceptModel().outputInfo().concepts(); assertEquals(1, concepts.size()); assertEquals("bar", concepts.get(0).name()); }
@Retry @Test public void t14b_addConceptsToModel_00() { assertSuccess(client.getModelByID(getModelID()).executeSync().get().asConceptModel() .modify().withConcepts(Action.MERGE, Concept.forID("outdoors23")) ); }
@Retry @Test public void t14c_addConceptsToModel_multi_lang() { assertSuccess(client.getModelByID(getModelID()).executeSync().get().asConceptModel() .modify().withConcepts(Action.MERGE, Concept.forID("outdoors23")).withLanguage("zh")); }
.withConcepts(Action.MERGE, Concept.forID("metro"), Concept.forID("family")) .executeSync().get(); model = model.train().executeSync().get().asConceptModel();