Skip to content

Commit

Permalink
google_mlkit_entity_extraction - v0.4.0 (flutter-ml#259)
Browse files Browse the repository at this point in the history
* Fix: EntityType enum order.
  • Loading branch information
fbernaly authored May 19, 2022
1 parent 83c67d1 commit 3cf4309
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 78 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2022-05-18

### Changes

---

Packages with changes:

- [`google_mlkit_entity_extraction` - `v0.4.0`](#google_mlkit_entity_extraction---v040)

---

#### `google_mlkit_entity_extraction` - `v0.4.0`

* Fix: EntityType enum order.

## 2022-05-06

### Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/google_ml_kit/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ PODS:
- google_mlkit_commons (0.2.0):
- Flutter
- MLKitVision
- google_mlkit_digital_ink_recognition (0.3.0):
- google_mlkit_digital_ink_recognition (0.4.0):
- Flutter
- google_mlkit_commons
- GoogleMLKit/DigitalInkRecognition (~> 2.6.0)
- google_mlkit_entity_extraction (0.3.0):
- google_mlkit_entity_extraction (0.4.0):
- Flutter
- google_mlkit_commons
- GoogleMLKit/EntityExtraction (~> 2.6.0)
Expand Down Expand Up @@ -478,8 +478,8 @@ SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
google_mlkit_barcode_scanning: 56e88993b6c915ce7134f9d77cb5b2de2fca8cfa
google_mlkit_commons: e9070f57232c3a3e4bd42fdfa621bb1f4bb3e709
google_mlkit_digital_ink_recognition: 7f3f58b2484d3887c30bcc1a00e9ca3bfbdb80ec
google_mlkit_entity_extraction: fd1d5168d887a0f79a31515faae7ac6e62792f07
google_mlkit_digital_ink_recognition: b5f915c6b5637a3b827dab42b59ca24b46243449
google_mlkit_entity_extraction: 0bf2407e9ad80934079721463dd69c3c66ecb413
google_mlkit_face_detection: 37e11922bc916867cf325589261efbe5cb46fd97
google_mlkit_image_labeling: 7f71f2310011308297c1b6ca5d67ef1c03ba9af9
google_mlkit_language_id: 39af954a7ff2ab556062e80bd0701bd377528647
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,67 +33,73 @@ class _EntityExtractionViewState extends State<EntityExtractionView> {
onTap: () {
FocusScope.of(context).unfocus();
},
child: ListView(
children: [
const SizedBox(
height: 20,
),
const Center(child: Text('Enter text (English)')),
Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
border: Border.all(
width: 2,
)),
child: TextField(
controller: _controller,
decoration: InputDecoration(border: InputBorder.none),
maxLines: null,
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(
height: 20,
),
const Center(child: Text('Enter text (English)')),
Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
border: Border.all(
width: 2,
)),
child: TextField(
controller: _controller,
decoration: InputDecoration(border: InputBorder.none),
maxLines: null,
),
),
),
),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
ElevatedButton(
onPressed: _extractEntities,
child: Text('Extract Entities'))
]),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: _downloadModel, child: Text('Download Model')),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
ElevatedButton(
onPressed: _deleteModel, child: Text('Delete Model')),
],
),
SizedBox(height: 20),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
ElevatedButton(
onPressed: _isModelDownloaded,
child: Text('Check download'))
]),
const SizedBox(
height: 30,
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: const Text('Result', style: TextStyle(fontSize: 20)),
),
ListView.builder(
padding: const EdgeInsets.symmetric(horizontal: 10),
shrinkWrap: true,
itemCount: _entities.length,
itemBuilder: (context, index) => ExpansionTile(
title: Text(_entities[index].text),
children: _entities[index]
.entities
.map((e) => Text(e.toString()))
.toList()),
),
],
onPressed: _extractEntities,
child: Text('Extract Entities'))
]),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: _downloadModel,
child: Text('Download Model')),
ElevatedButton(
onPressed: _deleteModel, child: Text('Delete Model')),
],
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: _isModelDownloaded,
child: Text('Check download'))
]),
const SizedBox(
height: 30,
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: const Text('Result', style: TextStyle(fontSize: 20)),
),
ListView.builder(
padding: const EdgeInsets.symmetric(horizontal: 10),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: _entities.length,
itemBuilder: (context, index) => ExpansionTile(
title: Text(_entities[index].text),
children: _entities[index]
.entities
.map((e) => Text('${e.type.name}: $e'))
.toList()),
),
],
),
),
),
),
Expand Down
4 changes: 4 additions & 0 deletions packages/google_mlkit_entity_extraction/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0

* Fix: EntityType enum order.

## 0.3.0

* Allow multiple instances in native layer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ - (void)handleDetection:(FlutterMethodCall *)call result:(FlutterResult)result {
[filters addObject:MLKEntityExtractionEntityTypeISBN];
break;
case 7:
[filters addObject:MLKEntityExtractionEntityTypeMoney];
[filters addObject:MLKEntityExtractionEntityTypePaymentCard];
break;
case 8:
[filters addObject:MLKEntityExtractionEntityTypePaymentCard];
[filters addObject:MLKEntityExtractionEntityTypePhone];
break;
case 9:
[filters addObject:MLKEntityExtractionEntityTypePhone];
[filters addObject:MLKEntityExtractionEntityTypeTrackingNumber];
break;
case 10:
[filters addObject:MLKEntityExtractionEntityTypeTrackingNumber];
[filters addObject:MLKEntityExtractionEntityTypeURL];
break;
case 11:
[filters addObject:MLKEntityExtractionEntityTypeURL];
[filters addObject:MLKEntityExtractionEntityTypeMoney];
break;
default:
break;
Expand Down Expand Up @@ -163,23 +163,23 @@ - (void)handleDetection:(FlutterMethodCall *)call result:(FlutterResult)result {
} else if ([entity.entityType isEqualToString: MLKEntityExtractionEntityTypeISBN]) {
type = 6;
entityData[@"isbn"] = entity.ISBNEntity.ISBN;
} else if ([entity.entityType isEqualToString: MLKEntityExtractionEntityTypeMoney]) {
type = 7;
entityData[@"fraction"] = @(entity.moneyEntity.fractionalPart);
entityData[@"integer"] = @(entity.moneyEntity.integerPart);
entityData[@"unnormalized"] = entity.moneyEntity.unnormalizedCurrency;
} else if ([entity.entityType isEqualToString: MLKEntityExtractionEntityTypePaymentCard]) {
type = 8;
type = 7;
entityData[@"network"] = @(entity.paymentCardEntity.paymentCardNetwork);
entityData[@"number"] = entity.paymentCardEntity.paymentCardNumber;
} else if ([entity.entityType isEqualToString: MLKEntityExtractionEntityTypePhone]) {
type = 9;
type = 8;
} else if ([entity.entityType isEqualToString: MLKEntityExtractionEntityTypeTrackingNumber]) {
type = 10;
type = 9;
entityData[@"carrier"] = @(entity.trackingNumberEntity.parcelCarrier);
entityData[@"number"] = entity.trackingNumberEntity.parcelTrackingNumber;
} else if ([entity.entityType isEqualToString: MLKEntityExtractionEntityTypeURL]) {
type = 11;
type = 10;
} else if ([entity.entityType isEqualToString: MLKEntityExtractionEntityTypeMoney]) {
type = 11;
entityData[@"fraction"] = @(entity.moneyEntity.fractionalPart);
entityData[@"integer"] = @(entity.moneyEntity.integerPart);
entityData[@"unnormalized"] = entity.moneyEntity.unnormalizedCurrency;
}

entityData[@"type"] = @(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ enum EntityType {
flightNumber,
iban,
isbn,
money,
paymentCard,
phone,
trackingNumber,
url,
money,
}

/// An entity extracted from a piece of text.
Expand Down
2 changes: 1 addition & 1 deletion packages/google_mlkit_entity_extraction/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: google_mlkit_entity_extraction
description: A Flutter plugin to use Google's ML Kit Entity Extractor API to recognize specific entities within static text.
version: 0.3.0
version: 0.4.0
homepage: https://github.com/bharat-biradar/Google-Ml-Kit-plugin

environment:
Expand Down

0 comments on commit 3cf4309

Please sign in to comment.