Skip to content

Commit 6fd4426

Browse files
committed
cleanup after review
1 parent e1a8760 commit 6fd4426

File tree

5 files changed

+9
-24
lines changed

5 files changed

+9
-24
lines changed

packages/mediapipe-task-text/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:flutter_lints/flutter.yaml
1+
include: ../analysis_options.yaml
22

33
# Additional information about this file can be found at
44
# https://dart.dev/guides/language/analysis-options
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
import 'package:mediapipe_text/mediapipe_text.dart';
22

33
export 'universal_text_classifier.dart'
4-
if (dart.library.html) 'web_text_classifier.dart'
5-
if (dart.library.io) 'ffi_text_classifier.dart';
4+
if (dart.library.html) 'text_classifier_web.dart'
5+
if (dart.library.io) 'text_classifier_io.dart';
66

77
/// Channel to analyze text via MediaPipe's text classification task.
88
abstract class BaseTextClassifier {
99
BaseTextClassifier({required this.options});
1010

11-
/// Configuration object passed into C or JavaScript to influence how
12-
/// MediaPipe completes the requested operation.
11+
/// Configuration object for tasks completed by this classifier.
1312
final TextClassifierOptions options;
1413

15-
/// Location for where to find the means to communicate with the MediaPipe SDK.
16-
///
17-
/// For mobile and desktop targets, this should be the location on the local
18-
/// filesystem of the C wrappers.
19-
///
20-
/// For web builds, this should be the namespace off the global `window`
21-
/// object where the JavaScript wrapper can be found.
22-
// final String sdkPath;
23-
2414
/// Sends a `String` value to MediaPipe for classification.
2515
TextClassifierResult classify(String text);
2616
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,22 @@ final _log = Logger('TextClassifier');
1111

1212
/// TextClassifier implementation able to use FFI and `dart:io`.
1313
class TextClassifier extends BaseTextClassifier {
14-
TextClassifier({required super.options, required super.sdkPath}) {
15-
_bindings = bindings.MediaPipeTextBindings(DynamicLibrary.open(sdkPath));
16-
}
17-
18-
late bindings.MediaPipeTextBindings _bindings;
14+
TextClassifier({required super.options});
1915

2016
@override
2117
TextClassifierResult classify(String text) {
2218
// Allocate and hydrate the configuration object
2319
final optionsPtr = options.toStruct();
2420
_log.finest('optionsPtr: $optionsPtr');
25-
final classifierPtr = _bindings.text_classifier_create(optionsPtr);
21+
final classifierPtr = bindings.text_classifier_create(optionsPtr);
2622
_log.finest('classifierPtr: $classifierPtr');
2723

2824
// Allocate the container for our results
2925
final resultsPtr = calloc<bindings.TextClassifierResult>();
3026
_log.finest('resultsPtr: $resultsPtr');
3127

3228
// Actually classify the text
33-
_bindings.text_classifier_classify(
29+
bindings.text_classifier_classify(
3430
classifierPtr,
3531
prepareString(text),
3632
resultsPtr,
@@ -39,7 +35,7 @@ class TextClassifier extends BaseTextClassifier {
3935
// Convert the results into pure-Dart objects and free all memory
4036
final result = TextClassifierResult.fromStruct(resultsPtr.ref);
4137
_log.fine('Text classification result: $result');
42-
_bindings.text_classifier_close(classifierPtr);
38+
bindings.text_classifier_close(classifierPtr);
4339
TextClassifierResult.freeStruct(resultsPtr);
4440
return result;
4541
}

packages/mediapipe-task-text/lib/src/tasks/text_classification/universal_text_classifier.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:mediapipe_text/mediapipe_text.dart';
22

33
/// Channel to classify text via MediaPipe's "classifyText" Task.
44
class TextClassifier extends BaseTextClassifier {
5-
TextClassifier({required super.options, required super.sdkPath}) {
5+
TextClassifier({required super.options}) {
66
throw Exception('Must use the web or FFI implementations');
77
}
88

packages/mediapipe-task-text/test/text_classifier_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'package:mediapipe_text/mediapipe_text.dart';
44
void main() {
55
group('FFI-based TextClassifier.classify should', () {
66
final classifier = TextClassifier(
7-
sdkPath: 'test/c/fake_text_classifier.dylib',
87
options: TextClassifierOptions.fromAssetPath('fake'),
98
);
109

0 commit comments

Comments
 (0)