Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions lib/services/mecab_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ class MecabService {
String baseReading = tokens[i].features[7];
if (baseReading.endsWith('ッ') &&
tokens[i].features[5] == '連用タ接続' &&
tokens.length > i + 1) {
tokens.length > i + 1 &&
tokens[i + 1].features.length == 9) {
switch (tokens[i + 1].features[6]) {
case 'て':
baseReading =
Expand All @@ -175,31 +176,32 @@ class MecabService {

// Check if the current token should be trailing of previous token
if (list.isNotEmpty) {
if (tokens[i - 1].features[5] == '連用タ接続') {
if (tokens[i - 1].features.length == 9 &&
tokens[i - 1].features[5] == '連用タ接続') {
list.last.trailing ??= [];
list.last.trailing!.add(current);
continue;
} else if (list.last.pos != PartOfSpeech.particle) {
if (tokens[i].features[1] == '接続助詞' && tokens[i].features[6] == 'て') {
list.last.trailing ??= [];
list.last.trailing!.add(current);
continue;
} else if (tokens[i].features[0] == '助動詞') {
if (tokens[i].features[6] == 'う' ||
tokens[i].features[6] == 'た' ||
tokens[i].features[6] == 'ます' ||
tokens[i].features[6] == 'ん' ||
tokens[i].features[6] == 'ない' ||
tokens[i].features[7] == 'ナ') {
if (tokens[i].features[1] == '接続助詞' && tokens[i].features[6] == 'て') {
list.last.trailing ??= [];
list.last.trailing!.add(current);
continue;
} else if (tokens[i].features[0] == '助動詞') {
if (tokens[i].features[6] == 'う' ||
tokens[i].features[6] == 'た' ||
tokens[i].features[6] == 'ます' ||
tokens[i].features[6] == 'ん' ||
tokens[i].features[6] == 'ない' ||
tokens[i].features[7] == 'ナ') {
list.last.trailing ??= [];
list.last.trailing!.add(current);
continue;
}
} else if (tokens[i].features[1] == '非自立' &&
tokens[i].features[6] == 'ん') {
list.last.trailing ??= [];
list.last.trailing!.add(current);
continue;
}
} else if (tokens[i].features[1] == '非自立' &&
tokens[i].features[6] == 'ん') {
list.last.trailing ??= [];
list.last.trailing!.add(current);
continue;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/about/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AboutView extends StackedView<AboutViewModel> {
'Sagase',
style: TextStyle(fontSize: 24),
),
const Text('1.4.0'),
const Text('1.4.1'),
const SizedBox(height: 16),
Text.rich(
textAlign: TextAlign.left,
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/views/changelog/changelog_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ class _ChangelogHistory extends StatelessWidget {
return const SizedBox(
width: double.infinity,
child: Markdown(data: '''
# [1.4.1]
- Fixed text analysis processing of incomplete conjugations
- Fixed a bug with search when the query rapidly changed
- Fixed a bug that caused shared lists to be empty
# [1.4.0]
- Added 2k, 6k, 10k, and Kaishi 1.5k vocab lists
- Added wildcard searching (e.g., "*心")
Expand Down
9 changes: 6 additions & 3 deletions lib/ui/views/dictionary_list/dictionary_list_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,12 @@ class DictionaryListViewModel extends FutureViewModel {
),
);

await file.writeAsString(
(dictionaryList as MyDictionaryList).toShareJson(),
);
await file.writeAsString((dictionaryList as MyDictionaryList)
.copyWith(
vocab: vocabList?.map((e) => e.id).toList() ?? [],
kanji: kanjiList?.map((e) => e.id).toList() ?? [],
)
.toShareJson());

// Share the file
await Share.shareXFiles([XFile(file.path)]);
Expand Down
61 changes: 34 additions & 27 deletions lib/ui/views/search/search_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SearchViewModel extends FutureViewModel {
String get searchString => _searchString;
List<DictionaryItem>? searchResult;

CancelableOperation<List<DictionaryItem>>? _searchOperation;
CancelableOperation<(List<DictionaryItem>, bool)>? _searchOperation;

bool _showHandWriting = false;
bool get showHandWriting => _showHandWriting;
Expand Down Expand Up @@ -66,40 +66,19 @@ class SearchViewModel extends FutureViewModel {

void searchOnChange(String value, {bool allowSkip = true}) {
String stringToSearch = value.trim();
// Prevent duplicate searches
if (stringToSearch == _searchString && allowSkip) return;
_searchString = stringToSearch;

if (_searchOperation != null) _searchOperation!.cancel();
_searchOperation?.cancel();

if (_searchString.isNotEmpty) {
_searchOperation = CancelableOperation.fromFuture(
_dictionaryService.searchDictionary(_searchString, _searchFilter),
_search(_searchString, _searchFilter),
);

_searchOperation!.value.then((value) async {
searchResult = value;
_searchOperation = null;
_promptAnalysis = false;

// If no results found for vocab search, try to analyze
if (_searchFilter == SearchFilter.vocab &&
searchResult!.isEmpty &&
!_kanaKit.isRomaji(stringToSearch)) {
final tokens = _mecabService.parseText(stringToSearch);

for (final token in tokens) {
final results =
await _dictionaryService.getVocabByJapaneseTextToken(token);

if (results.isNotEmpty) {
searchResult!.add(results[0]);
}
}

_promptAnalysis = searchResult!.isNotEmpty;
}

_searchOperation!.then((value) {
searchResult = value.$1;
_promptAnalysis = value.$2;
notifyListeners();
});

Expand All @@ -125,6 +104,34 @@ class SearchViewModel extends FutureViewModel {
}
}

Future<(List<DictionaryItem>, bool)> _search(
String query,
SearchFilter filter,
) async {
final results = await _dictionaryService.searchDictionary(query, filter);

bool promptAnalysis = false;

if (filter == SearchFilter.vocab &&
results.isEmpty &&
!_kanaKit.isRomaji(query)) {
final tokens = _mecabService.parseText(query);

for (final token in tokens) {
final tokenResults =
await _dictionaryService.getVocabByJapaneseTextToken(token);

if (tokenResults.isNotEmpty) {
results.add(tokenResults[0]);
}
}

promptAnalysis = results.isNotEmpty;
}

return (results, promptAnalysis);
}

void toggleHandWriting() {
if (!_digitalInkService.ready) {
if (!_snackbarService.isSnackbarOpen) {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1165,8 +1165,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: b7b0a25
resolved-ref: b7b0a25bb447c560ea4e629c10c745d1ec4ab244
ref: "4ea66ef"
resolved-ref: "4ea66efb580193c1c312efbeb828ffa44c33a999"
url: "https://github.com/Moseco/sagase_dictionary"
source: git
version: "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A Japanese-English dictionary and learning app.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.4.0+20
version: 1.4.1+22

environment:
sdk: '>=3.0.5 <4.0.0'
Expand Down Expand Up @@ -71,7 +71,7 @@ dependencies:
sagase_dictionary:
git:
url: https://github.com/Moseco/sagase_dictionary
ref: 'b7b0a25'
ref: '4ea66ef'
url_launcher: ^6.1.12
dio: ^5.3.3
in_app_review: ^2.0.8
Expand Down