Search in sources :

Example 1 with TextFormatType

use of com.amplifyframework.predictions.models.TextFormatType in project amplify-android by aws-amplify.

the class IdentifyTextConfiguration method fromJson.

/**
 * Construct an instance of {@link IdentifyTextConfiguration} from
 * plugin configuration JSON object.
 * @param configurationJson the plugin configuration
 * @return the configuration for text identification
 * @throws JSONException if identify configuration is malformed
 */
@Nullable
public static IdentifyTextConfiguration fromJson(@NonNull JSONObject configurationJson) throws JSONException {
    if (!configurationJson.has(CONFIG_NAME)) {
        return null;
    }
    JSONObject identifyLabelsJson = configurationJson.getJSONObject(CONFIG_NAME);
    String formatString = identifyLabelsJson.getString("format");
    String networkPolicyString = identifyLabelsJson.getString("defaultNetworkPolicy");
    final TextFormatType format = TextFormatType.valueOf(formatString);
    final NetworkPolicy networkPolicy = NetworkPolicy.fromKey(networkPolicyString);
    return new IdentifyTextConfiguration(format, networkPolicy);
}
Also used : TextFormatType(com.amplifyframework.predictions.models.TextFormatType) JSONObject(org.json.JSONObject) NetworkPolicy(com.amplifyframework.predictions.aws.NetworkPolicy) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)1 NetworkPolicy (com.amplifyframework.predictions.aws.NetworkPolicy)1 TextFormatType (com.amplifyframework.predictions.models.TextFormatType)1 JSONObject (org.json.JSONObject)1