refactor ml utils
This commit is contained in:
@@ -3,13 +3,12 @@ import 'dart:async';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:flutter_mozilla_components/ml_utils.dart';
|
||||
import 'package:nullability/nullability.dart';
|
||||
import 'package:riverpod/riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/providers.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/utils/embedding_text_processing.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/utils/nearest_neighbor.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
|
||||
import 'package:weblibre/utils/lru_cache.dart';
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export 'src/utils/ml/embedding_text_processing.dart';
|
||||
export 'src/utils/ml/nearest_neighbor.dart';
|
||||
+6
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
/// Calculates cosine similarity between two lists of floats
|
||||
+6
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
/// Removes trailing domain-related text such as '... - Mail' or '... | News'
|
||||
/// If there's not enough information remaining after, we keep the text as is
|
||||
/// [text] tab title with potential domain information
|
||||
+7
-1
@@ -1,5 +1,11 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/utils/cosine_similarity.dart';
|
||||
import 'package:flutter_mozilla_components/src/utils/ml/cosine_similarity.dart';
|
||||
|
||||
List<String> findNearestNeighborsRecursive({
|
||||
required Map<String, List<double>> embeddings,
|
||||
@@ -8,6 +8,7 @@ environment:
|
||||
flutter: '>=3.3.0'
|
||||
|
||||
dependencies:
|
||||
collection: ^1.19.1
|
||||
flutter:
|
||||
sdk: flutter
|
||||
rxdart: ^0.28.0
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter_mozilla_components/src/utils/ml/embedding_text_processing.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/utils/embedding_text_processing.dart';
|
||||
|
||||
void main() {
|
||||
group('Text processing basic cases', () {
|
||||
Reference in New Issue
Block a user