Created
August 17, 2021 05:24
-
-
Save DanishAmjad12/67ddd75449c641d605e0af0fea135312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
entityExtractor | |
.downloadModelIfNeeded() | |
.addOnSuccessListener { _ -> | |
//step3 | |
val params = | |
EntityExtractionParams.Builder("My flight is LX373") | |
.build() | |
entityExtractor | |
.annotate(params) | |
.addOnSuccessListener { | |
//step4 | |
for (entityAnnotation in it) { | |
val entities: List<Entity> = entityAnnotation.entities | |
Log.d("VALUE", "Range: ${entityAnnotation.start} - ${entityAnnotation.end}") | |
for (entity in entities) { | |
when (entity) { | |
is DateTimeEntity -> { | |
result.text="Granularity: ${entity.dateTimeGranularity} \n TimeStamp: ${entity.timestampMillis}" | |
Log.d("VALUE", "Granularity: ${entity.dateTimeGranularity}") | |
Log.d("VALUE", "TimeStamp: ${entity.timestampMillis}") | |
} | |
is FlightNumberEntity -> { | |
result.text= "Airline Code: ${entity.airlineCode} \nFlight number: ${entity.flightNumber}" | |
Log.d("VALUE", "Airline Code: ${entity.airlineCode}") | |
Log.d("VALUE", "Flight number: ${entity.flightNumber}") | |
} | |
else -> { | |
Log.d("VALUE", " $entity") | |
} | |
} | |
} | |
} | |
} | |
.addOnFailureListener { | |
// Check failure message here. | |
} | |
} | |
.addOnFailureListener { _ -> /* Model downloading failed. */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment