treewide: add and apply a bunch of lints
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:jadb/_data_ingestion/open_local_db.dart';
|
||||
import 'package:jadb/_data_ingestion/seed_database.dart';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:jadb/cli/args.dart';
|
||||
|
||||
class CreateDb extends Command {
|
||||
final name = "create-db";
|
||||
final description = "Create the database";
|
||||
@override
|
||||
final name = 'create-db';
|
||||
@override
|
||||
final description = 'Create the database';
|
||||
|
||||
CreateDb() {
|
||||
addLibsqliteArg(argParser);
|
||||
@@ -23,6 +24,7 @@ class CreateDb extends Command {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> run() async {
|
||||
if (argResults!.option('libsqlite') == null) {
|
||||
print(argParser.usage);
|
||||
@@ -38,10 +40,10 @@ class CreateDb extends Command {
|
||||
bool failed = false;
|
||||
await seedData(db)
|
||||
.then((_) {
|
||||
print("Database created successfully");
|
||||
print('Database created successfully');
|
||||
})
|
||||
.catchError((error) {
|
||||
print("Error creating database: $error");
|
||||
print('Error creating database: $error');
|
||||
failed = true;
|
||||
})
|
||||
.whenComplete(() {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:jadb/_data_ingestion/open_local_db.dart';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:jadb/_data_ingestion/open_local_db.dart';
|
||||
import 'package:jadb/_data_ingestion/tanos-jlpt/csv_parser.dart';
|
||||
import 'package:jadb/_data_ingestion/tanos-jlpt/objects.dart';
|
||||
import 'package:jadb/_data_ingestion/tanos-jlpt/resolve.dart';
|
||||
@@ -10,9 +9,11 @@ import 'package:jadb/cli/args.dart';
|
||||
import 'package:sqflite_common/sqlite_api.dart';
|
||||
|
||||
class CreateTanosJlptMappings extends Command {
|
||||
final name = "create-tanos-jlpt-mappings";
|
||||
@override
|
||||
final name = 'create-tanos-jlpt-mappings';
|
||||
@override
|
||||
final description =
|
||||
"Resolve Tanos JLPT data against JMDict. This tool is useful to create overrides for ambiguous references";
|
||||
'Resolve Tanos JLPT data against JMDict. This tool is useful to create overrides for ambiguous references';
|
||||
|
||||
CreateTanosJlptMappings() {
|
||||
addLibsqliteArg(argParser);
|
||||
@@ -26,6 +27,7 @@ class CreateTanosJlptMappings extends Command {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> run() async {
|
||||
if (argResults!.option('libsqlite') == null ||
|
||||
argResults!.option('jadb') == null) {
|
||||
@@ -40,7 +42,7 @@ class CreateTanosJlptMappings extends Command {
|
||||
|
||||
final useOverrides = argResults!.flag('overrides');
|
||||
|
||||
Map<String, File> files = {
|
||||
final Map<String, File> files = {
|
||||
'N1': File('data/tanos-jlpt/n1.csv'),
|
||||
'N2': File('data/tanos-jlpt/n2.csv'),
|
||||
'N3': File('data/tanos-jlpt/n3.csv'),
|
||||
@@ -59,7 +61,7 @@ Future<void> resolveExisting(
|
||||
Database db,
|
||||
bool useOverrides,
|
||||
) async {
|
||||
List<JLPTRankedWord> missingWords = [];
|
||||
final List<JLPTRankedWord> missingWords = [];
|
||||
for (final (i, word) in rankedWords.indexed) {
|
||||
try {
|
||||
print(
|
||||
@@ -90,7 +92,7 @@ Future<void> resolveExisting(
|
||||
.toStringAsFixed(2);
|
||||
|
||||
print(
|
||||
'${jlptLevel} failures: [${missingWordCount}/${totalWordCount}] (${failureRate}%)',
|
||||
'$jlptLevel failures: [$missingWordCount/$totalWordCount] ($failureRate%)',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
// import 'package:jadb/_data_ingestion/open_local_db.dart';
|
||||
import 'package:jadb/cli/args.dart';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:jadb/util/lemmatizer/lemmatizer.dart';
|
||||
|
||||
class Lemmatize extends Command {
|
||||
final name = "lemmatize";
|
||||
final description = "Lemmatize a word using the Jadb lemmatizer";
|
||||
@override
|
||||
final name = 'lemmatize';
|
||||
@override
|
||||
final description = 'Lemmatize a word using the Jadb lemmatizer';
|
||||
|
||||
Lemmatize() {
|
||||
addLibsqliteArg(argParser);
|
||||
@@ -21,6 +22,7 @@ class Lemmatize extends Command {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> run() async {
|
||||
// if (argResults!.option('libsqlite') == null ||
|
||||
// argResults!.option('jadb') == null) {
|
||||
@@ -41,6 +43,6 @@ class Lemmatize extends Command {
|
||||
|
||||
print(result.toString());
|
||||
|
||||
print("Lemmatization took ${time.elapsedMilliseconds}ms");
|
||||
print('Lemmatization took ${time.elapsedMilliseconds}ms');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:jadb/_data_ingestion/open_local_db.dart';
|
||||
import 'package:jadb/cli/args.dart';
|
||||
import 'package:jadb/search.dart';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
class QueryKanji extends Command {
|
||||
final name = "query-kanji";
|
||||
final description = "Query the database for kanji data";
|
||||
final invocation = "jadb query-kanji [options] <kanji>";
|
||||
@override
|
||||
final name = 'query-kanji';
|
||||
@override
|
||||
final description = 'Query the database for kanji data';
|
||||
@override
|
||||
final invocation = 'jadb query-kanji [options] <kanji>';
|
||||
|
||||
QueryKanji() {
|
||||
addLibsqliteArg(argParser);
|
||||
addJadbArg(argParser);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> run() async {
|
||||
if (argResults!.option('libsqlite') == null ||
|
||||
argResults!.option('jadb') == null) {
|
||||
@@ -43,11 +46,11 @@ class QueryKanji extends Command {
|
||||
time.stop();
|
||||
|
||||
if (result == null) {
|
||||
print("No such kanji");
|
||||
print('No such kanji');
|
||||
} else {
|
||||
print(JsonEncoder.withIndent(' ').convert(result.toJson()));
|
||||
}
|
||||
|
||||
print("Query took ${time.elapsedMilliseconds}ms");
|
||||
print('Query took ${time.elapsedMilliseconds}ms');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:jadb/_data_ingestion/open_local_db.dart';
|
||||
import 'package:jadb/cli/args.dart';
|
||||
import 'package:jadb/search.dart';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:sqflite_common/sqflite.dart';
|
||||
|
||||
class QueryWord extends Command {
|
||||
final name = "query-word";
|
||||
final description = "Query the database for word data";
|
||||
final invocation = "jadb query-word [options] (<word> | <ID>)";
|
||||
@override
|
||||
final name = 'query-word';
|
||||
@override
|
||||
final description = 'Query the database for word data';
|
||||
@override
|
||||
final invocation = 'jadb query-word [options] (<word> | <ID>)';
|
||||
|
||||
QueryWord() {
|
||||
addLibsqliteArg(argParser);
|
||||
@@ -24,10 +26,11 @@ class QueryWord extends Command {
|
||||
argParser.addOption('pageSize', valueHelp: 'NUM', defaultsTo: '30');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> run() async {
|
||||
if (argResults!.option('libsqlite') == null ||
|
||||
argResults!.option('jadb') == null) {
|
||||
print("You need to provide both libsqlite and jadb paths.");
|
||||
print('You need to provide both libsqlite and jadb paths.');
|
||||
print('');
|
||||
printUsage();
|
||||
exit(64);
|
||||
@@ -45,7 +48,7 @@ class QueryWord extends Command {
|
||||
exit(64);
|
||||
}
|
||||
|
||||
final String searchWord = argResults!.rest.join(" ");
|
||||
final String searchWord = argResults!.rest.join(' ');
|
||||
final int? maybeId = int.tryParse(searchWord);
|
||||
|
||||
if (maybeId != null && maybeId >= 1000000) {
|
||||
@@ -67,7 +70,7 @@ class QueryWord extends Command {
|
||||
time.stop();
|
||||
|
||||
if (result == null) {
|
||||
print("Invalid ID");
|
||||
print('Invalid ID');
|
||||
} else {
|
||||
if (jsonOutput) {
|
||||
print(JsonEncoder.withIndent(' ').convert(result));
|
||||
@@ -76,7 +79,7 @@ class QueryWord extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
print("Query took ${time.elapsedMilliseconds}ms");
|
||||
print('Query took ${time.elapsedMilliseconds}ms');
|
||||
}
|
||||
|
||||
Future<void> _searchWord(
|
||||
@@ -97,22 +100,22 @@ class QueryWord extends Command {
|
||||
time2.stop();
|
||||
|
||||
if (result == null) {
|
||||
print("Invalid search");
|
||||
print('Invalid search');
|
||||
} else if (result.isEmpty) {
|
||||
print("No matches");
|
||||
print('No matches');
|
||||
} else {
|
||||
if (jsonOutput) {
|
||||
print(JsonEncoder.withIndent(' ').convert(result));
|
||||
} else {
|
||||
for (final e in result) {
|
||||
print(e.toString());
|
||||
print("");
|
||||
print('');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print("Total count: ${count}");
|
||||
print("Count query took ${time.elapsedMilliseconds}ms");
|
||||
print("Query took ${time2.elapsedMilliseconds}ms");
|
||||
print('Total count: $count');
|
||||
print('Count query took ${time.elapsedMilliseconds}ms');
|
||||
print('Query took ${time2.elapsedMilliseconds}ms');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user