Sorting a matrix with symbolic variables in matlab - matlab

How can i sort or arrange this matrix ? The 10th row is showing up now in the very start while it should follow the sequence and comes at 10th place. Few other elements are also misplaced in the middle. All the variables are symbolic in this case. Thank you.
[ P10_1, P10_10, P10_2, P10_3, P10_4, P10_5, P10_6, P10_7, P10_8, P10_9, P1_1, P1_10, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P2_1, P2_10, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7, P2_8, P2_9, P3_1, P3_10, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7, P3_8, P3_9, P4_1, P4_10, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7, P4_8, P4_9, P5_1, P5_10, P5_2, P5_3, P5_4, P5_5, P5_6, P5_7, P5_8, P5_9, P6_1, P6_10, P6_2, P6_3, P6_4, P6_5, P6_6, P6_7, P6_8, P6_9, P7_1, P7_10, P7_2, P7_3, P7_4, P7_5, P7_6, P7_7, P7_8, P7_9, P8_1, P8_10, P8_2, P8_3, P8_4, P8_5, P8_6, P8_7, P8_8, P8_9, P9_1, P9_10, P9_2, P9_3, P9_4, P9_5, P9_6, P9_7, P9_8, P9_9]
The sort function return this.The 10th row should come in the end but it is appearing in the start.
[ P10_1, P10_2, P10_3, P10_4, P10_5, P10_6, P10_7, P10_8, P10_9, P10_10, P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7, P2_8, P2_9, P3_1, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7, P3_8, P3_9, P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7, P4_8, P4_9, P5_1, P5_2, P5_3, P5_4, P5_5, P5_6, P5_7, P5_8, P5_9, P6_1, P6_2, P6_3, P6_4, P6_5, P6_6, P6_7, P6_8, P6_9, P7_1, P7_2, P7_3, P7_4, P7_5, P7_6, P7_7, P7_8, P7_9, P8_1, P8_2, P8_3, P8_4, P8_5, P8_6, P8_7, P8_8, P8_9, P9_1, P9_2, P9_3, P9_4, P9_5, P9_6, P9_7, P9_8, P9_9, P1_10, P2_10, P3_10, P4_10, P5_10, P6_10, P7_10, P8_10, P9_10]

horchler suggested in the comments to create proper variable names to make lexicographic sorting using sort work properly. I think this is a very good idea, but unfortunately the format string he suggests does not work. It always pads a zero, ending up with this:
>> P1 = sym('P0%d_0%d',10)
P =
[ P01_01, P01_02, P01_03, P01_04, P01_05, P01_06, P01_07, P01_08, P01_09, P01_010]
[ P02_01, P02_02, P02_03, P02_04, P02_05, P02_06, P02_07, P02_08, P02_09, P02_010]
[ P03_01, P03_02, P03_03, P03_04, P03_05, P03_06, P03_07, P03_08, P03_09, P03_010]
[ P04_01, P04_02, P04_03, P04_04, P04_05, P04_06, P04_07, P04_08, P04_09, P04_010]
[ P05_01, P05_02, P05_03, P05_04, P05_05, P05_06, P05_07, P05_08, P05_09, P05_010]
[ P06_01, P06_02, P06_03, P06_04, P06_05, P06_06, P06_07, P06_08, P06_09, P06_010]
[ P07_01, P07_02, P07_03, P07_04, P07_05, P07_06, P07_07, P07_08, P07_09, P07_010]
[ P08_01, P08_02, P08_03, P08_04, P08_05, P08_06, P08_07, P08_08, P08_09, P08_010]
[ P09_01, P09_02, P09_03, P09_04, P09_05, P09_06, P09_07, P09_08, P09_09, P09_010]
[ P010_01, P010_02, P010_03, P010_04, P010_05, P010_06, P010_07, P010_08, P010_09, P010_010]
I tried to fix the format string but failed. MATLAB refuses to accept the format string which would be needed:
>> P1 = sym('P%.2d_%.2d',10)
Error using sym>createCharMatrix (line
2172)
Symbolic matrix base name must be a
simple variable name.
Error in sym>convertCharWithOption
(line 2138)
s = createCharMatrix(x,a);
Error in sym>tomupad (line 1871)
S = convertCharWithOption(x,a);
Error in sym (line 109)
S.s = tomupad(x,a);
So I wrote my own function to fix this:
function [ s ] = symMatrix( A,set )
%preallocate an empty matrix to fill it in the loop
s=sym(zeros(set));
%just some math t get the required amount of digits.
digits=ceil(log10(max(set)+1));
%generate format string with required digits. Check documentation of sprintf for details
format=['%s%.',num2str(digits),'d_%.',num2str(digits),'d'];
%finally go through the matrix...
for r=1:set(1)
for c=1:set(2)
%...get the right name for each variable ....
sprintf(format,A,r,c);
%...and create a variable with that name.
s(r,c)=sym(n);
end
end
end
Which produces this result:
>> P2=symMatrix('P',[11,11])
P2 =
[ P01_01, P01_02, P01_03, P01_04, P01_05, P01_06, P01_07, P01_08, P01_09, P01_10, P01_11]
[ P02_01, P02_02, P02_03, P02_04, P02_05, P02_06, P02_07, P02_08, P02_09, P02_10, P02_11]
[ P03_01, P03_02, P03_03, P03_04, P03_05, P03_06, P03_07, P03_08, P03_09, P03_10, P03_11]
[ P04_01, P04_02, P04_03, P04_04, P04_05, P04_06, P04_07, P04_08, P04_09, P04_10, P04_11]
[ P05_01, P05_02, P05_03, P05_04, P05_05, P05_06, P05_07, P05_08, P05_09, P05_10, P05_11]
[ P06_01, P06_02, P06_03, P06_04, P06_05, P06_06, P06_07, P06_08, P06_09, P06_10, P06_11]
[ P07_01, P07_02, P07_03, P07_04, P07_05, P07_06, P07_07, P07_08, P07_09, P07_10, P07_11]
[ P08_01, P08_02, P08_03, P08_04, P08_05, P08_06, P08_07, P08_08, P08_09, P08_10, P08_11]
[ P09_01, P09_02, P09_03, P09_04, P09_05, P09_06, P09_07, P09_08, P09_09, P09_10, P09_11]
[ P10_01, P10_02, P10_03, P10_04, P10_05, P10_06, P10_07, P10_08, P10_09, P10_10, P10_11]
[ P11_01, P11_02, P11_03, P11_04, P11_05, P11_06, P11_07, P11_08, P11_09, P11_10, P11_11]
Finally compare the sorting of all three possibilities:
>> P3=sym('P',[11,11])
P3 =
[ P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P1_10, P1_11]
[ P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7, P2_8, P2_9, P2_10, P2_11]
[ P3_1, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7, P3_8, P3_9, P3_10, P3_11]
[ P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7, P4_8, P4_9, P4_10, P4_11]
[ P5_1, P5_2, P5_3, P5_4, P5_5, P5_6, P5_7, P5_8, P5_9, P5_10, P5_11]
[ P6_1, P6_2, P6_3, P6_4, P6_5, P6_6, P6_7, P6_8, P6_9, P6_10, P6_11]
[ P7_1, P7_2, P7_3, P7_4, P7_5, P7_6, P7_7, P7_8, P7_9, P7_10, P7_11]
[ P8_1, P8_2, P8_3, P8_4, P8_5, P8_6, P8_7, P8_8, P8_9, P8_10, P8_11]
[ P9_1, P9_2, P9_3, P9_4, P9_5, P9_6, P9_7, P9_8, P9_9, P9_10, P9_11]
[ P10_1, P10_2, P10_3, P10_4, P10_5, P10_6, P10_7, P10_8, P10_9, P10_10, P10_11]
[ P11_1, P11_2, P11_3, P11_4, P11_5, P11_6, P11_7, P11_8, P11_9, P11_10, P11_11]
>> sort(P1(:)).' %P1 = sym('P0%d_0%d',10)
ans =
[ P01_01, P01_02, P01_03, P01_04, P01_05, P01_06, P01_07, P01_08, P01_09, P02_01, P02_02, P02_03, P02_04, P02_05, P02_06, P02_07, P02_08, P02_09, P03_01, P03_02, P03_03, P03_04, P03_05, P03_06, P03_07, P03_08, P03_09, P04_01, P04_02, P04_03, P04_04, P04_05, P04_06, P04_07, P04_08, P04_09, P05_01, P05_02, P05_03, P05_04, P05_05, P05_06, P05_07, P05_08, P05_09, P06_01, P06_02, P06_03, P06_04, P06_05, P06_06, P06_07, P06_08, P06_09, P07_01, P07_02, P07_03, P07_04, P07_05, P07_06, P07_07, P07_08, P07_09, P08_01, P08_02, P08_03, P08_04, P08_05, P08_06, P08_07, P08_08, P08_09, P09_01, P09_02, P09_03, P09_04, P09_05, P09_06, P09_07, P09_08, P09_09, P010_01, P010_02, P010_03, P010_04, P010_05, P010_06, P010_07, P010_08, P010_09, P01_010, P02_010, P03_010, P04_010, P05_010, P06_010, P07_010, P08_010, P09_010, P010_010]
>> sort(P2(:)).' %P2=symMatrix('P',[11,11])
ans =
[ P01_01, P01_02, P01_03, P01_04, P01_05, P01_06, P01_07, P01_08, P01_09, P01_10, P01_11, P02_01, P02_02, P02_03, P02_04, P02_05, P02_06, P02_07, P02_08, P02_09, P02_10, P02_11, P03_01, P03_02, P03_03, P03_04, P03_05, P03_06, P03_07, P03_08, P03_09, P03_10, P03_11, P04_01, P04_02, P04_03, P04_04, P04_05, P04_06, P04_07, P04_08, P04_09, P04_10, P04_11, P05_01, P05_02, P05_03, P05_04, P05_05, P05_06, P05_07, P05_08, P05_09, P05_10, P05_11, P06_01, P06_02, P06_03, P06_04, P06_05, P06_06, P06_07, P06_08, P06_09, P06_10, P06_11, P07_01, P07_02, P07_03, P07_04, P07_05, P07_06, P07_07, P07_08, P07_09, P07_10, P07_11, P08_01, P08_02, P08_03, P08_04, P08_05, P08_06, P08_07, P08_08, P08_09, P08_10, P08_11, P09_01, P09_02, P09_03, P09_04, P09_05, P09_06, P09_07, P09_08, P09_09, P09_10, P09_11, P10_01, P10_02, P10_03, P10_04, P10_05, P10_06, P10_07, P10_08, P10_09, P10_10, P10_11, P11_01, P11_02, P11_03, P11_04, P11_05, P11_06, P11_07, P11_08, P11_09, P11_10, P11_11]
>> sort(P3(:)).' %P3 = sym('P',10)
ans =
[ P10_1, P10_2, P10_3, P10_4, P10_5, P10_6, P10_7, P10_8, P10_9, P11_1, P11_2, P11_3, P11_4, P11_5, P11_6, P11_7, P11_8, P11_9, P10_10, P10_11, P11_10, P11_11, P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7, P2_8, P2_9, P3_1, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7, P3_8, P3_9, P4_1, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7, P4_8, P4_9, P5_1, P5_2, P5_3, P5_4, P5_5, P5_6, P5_7, P5_8, P5_9, P6_1, P6_2, P6_3, P6_4, P6_5, P6_6, P6_7, P6_8, P6_9, P7_1, P7_2, P7_3, P7_4, P7_5, P7_6, P7_7, P7_8, P7_9, P8_1, P8_2, P8_3, P8_4, P8_5, P8_6, P8_7, P8_8, P8_9, P9_1, P9_2, P9_3, P9_4, P9_5, P9_6, P9_7, P9_8, P9_9, P1_10, P1_11, P2_10, P2_11, P3_10, P3_11, P4_10, P4_11, P5_10, P5_11, P6_10, P6_11, P7_10, P7_11, P8_10, P8_11, P9_10, P9_11]

I don't know what you mean with "symbolic"? When it's a string, simple parse them as numbers (remove 'P' and replace the underscore '_' with a dot '.').
Finally sort while saving the indices.
this = '[ P10_1, P10_10, P10_2, P10_3, P10_4, P10_5, P10_6, P10_7, P10_8, P10_9, P1_1, P1_10, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7, P1_8, P1_9, P2_1, P2_10, P2_2, P2_3, P2_4, P2_5, P2_6, P2_7, P2_8, P2_9, P3_1, P3_10, P3_2, P3_3, P3_4, P3_5, P3_6, P3_7, P3_8, P3_9, P4_1, P4_10, P4_2, P4_3, P4_4, P4_5, P4_6, P4_7, P4_8, P4_9, P5_1, P5_10, P5_2, P5_3, P5_4, P5_5, P5_6, P5_7, P5_8, P5_9, P6_1, P6_10, P6_2, P6_3, P6_4, P6_5, P6_6, P6_7, P6_8, P6_9, P7_1, P7_10, P7_2, P7_3, P7_4, P7_5, P7_6, P7_7, P7_8, P7_9, P8_1, P8_10, P8_2, P8_3, P8_4, P8_5, P8_6, P8_7, P8_8, P8_9, P9_1, P9_10, P9_2, P9_3, P9_4, P9_5, P9_6, P9_7, P9_8, P9_9]';
% this is the ugly part :)
original = regexp([regexprep(this, {'\[','\]'}, {'',''}) ','], '(.*?),', 'tokens');
m = eval(regexprep(this, {'_', 'P'},{'.',''}));
[s, idx] = sort(m);
original(idx)
As you see, this just works partly, because "symbolic" P10_1 < P10_10, but on numeric level, they're equal. So you just need to figure out to handle it, e.g. ensure you always have two decimal places and complete a leading zero if not.
If it's not a string, ignore this :)

Related

Why isn't my translator system working in flutter?

I'm attempt to do a localization translator in flutter for my project. I got help from this tutorial:
https://resocoder.com/2019/06/01/flutter-localization-the-easy-way-internationalization-with-json/
But when I run the program, it only show one language even when I change the language in the laptop setting (I use Chrome for debugging so i had to change language from the laptop setting).
Here's my code:
MAIN.dart:
import 'package:final_translating_test/taylake.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'app_localizations.dart';
import 'dakmilprison.dart';
import 'damw.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
routes: {
'/1': (context) => TayLake(),
'/2': (context) => DamW(),
'/3': (context) => DakMilPrison(),
},
supportedLocales: [Locale('en', 'US'), Locale('vi', 'VN')],
localizationsDelegates: [
// THIS CLASS WILL BE ADDED LATER
// A class which loads the translations from JSON files
AppLocalizations.delegate,
// Built-in localization of basic text for Material widgets
GlobalMaterialLocalizations.delegate,
// Built-in localization for text direction LTR/RTL
GlobalWidgetsLocalizations.delegate,
],
localeResolutionCallback: (locale, supportedLocales) {
for (var supportedLocale in supportedLocales) {
if (supportedLocale.languageCode == locale!.languageCode &&
supportedLocale.countryCode == locale.countryCode) {
return supportedLocale;
}
}
return supportedLocales.first;
},
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({
Key? key,
}) : super(key: key);
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Stack(
children: [
Image.network(
'https://t4.ftcdn.net/jpg/03/36/07/85/240_F_336078503_3rIlo0PPrbrxyPbR99qXVo6VATqWsHvl.jpg',
filterQuality: FilterQuality.high,
fit: BoxFit.fitWidth,
width: 500,
),
ListTile(
leading:
Icon(Icons.menu_outlined, color: Colors.white, size: 30),
trailing: Icon(Icons.verified_user_outlined,
size: 30, color: Colors.white),
),
],
),
Expanded(
child: PageView(
children: <Widget>[
placeButton(
context,
"titleHoTay",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRLRsM_lVQtJSMBRgTzeyPIrqdeMFV7M3gCzA&usqp=CAU",
"/1"),
placeButton(
context,
"titleDapW",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTabeU7lO71WhEE3EY99nU087Xwlj5PAPd76g&usqp=CAU",
"/2"),
placeButton(
context,
"titleNhaNgucDm",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSzl8XkPISxI0Uqcy0FR6g3cRvtng1Ghu6T9w&usqp=CAUs",
"/3")
],
),
),
],
),
);
}
}
Widget placeButton(BuildContext context, String name, String image, String id) {
return Column(children: [
Padding(
padding: const EdgeInsets.fromLTRB(130.0, 0.0, 130.00, 0.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: SizedBox(
height: 300,
width: 400,
child: GestureDetector(
onTap: () {
Navigator.pushNamed(context, id);
},
child: Card(
child: ListTile(
title: Padding(
padding: const EdgeInsets.fromLTRB(20, 5, 20, 0),
child: Text(AppLocalizations.of(context)!.translate(name),
style: TextStyle(fontFamily: 'Manrope', fontSize: 18)),
),
subtitle: Image.network(
image,
height: 250,
),
),
),
),
),
),
),
Container(
height: 40,
width: 200,
padding: EdgeInsets.only(top: 0),
color: Colors.white,
child: ListTile(
leading: Text(
"Rating:",
style: TextStyle(fontFamily: 'Klasik'),
),
trailing: IconButton(
splashRadius: 20,
icon: Icon(Icons.star_border_outlined),
onPressed: () {},
),
),
),
]);
}
APP_LOCALIZATIONS.dart:
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class AppLocalizations {
final Locale locale;
AppLocalizations (this.locale);
static AppLocalizations? of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
late Map<String, String> _localizedStrings;
Future<bool> load() async {
String jsonString =
await rootBundle.loadString('lang/${locale.languageCode}.json');
Map<String, dynamic> jsonMap = json.decode(jsonString);
_localizedStrings = jsonMap.map((key, value) {
return MapEntry(key, value.toString());
});
return true;
}
String translate(String key) {
return _localizedStrings[key]!;
}
}
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
#override
bool isSupported(Locale locale) {
return ['en', 'vi'].contains(locale.languageCode);
}
#override
Future<AppLocalizations> load(Locale locale) async {
AppLocalizations localizations = new AppLocalizations(locale);
await localizations.load();
return localizations;
}
#override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
en.JSON:
{
"first_string": "Hello! This is the first message.",
"second_string": "If this tutorial helps you, give it a like and subscribe to Reso Coder 😉",
"titleHoTay": "Tay Lake",
"titleDapW": "W Dam",
"titleNhaNgucDm": "DakMil Prison",
"GioiThieu": "Introduction",
"GioiThieuHoTay": "West Lake Dak Mil is an extremely familiar destination for people in the small town of Dak Mil, which not only plays the role of regulating and creating a balance in the landscape for this beautiful town, but also a tourist destination which attracts young people and tourists by the poetic and peaceful scenery. If you have the opportunity to come to the small town of Dak Mil of Dak Nong province, do not forget to check-in at this extremely hot destination.",
"LichSu": "History",
"LichSuHoTay": "West Lake in Dak Mil is a semi-artificial lake, formed in the 1940s. Initially, the lake was planned by the French colonialists to store water for the coffee growing project in Dak Nong. Until 1982, the town continued to invest in expanding the lake surface to better serve the irrigation needs of the people and at the same time become a place to store water from underground aquifers. It is also for this reason that the water here is always blue all year round.",
"ViTriDiaLy": "Geological Location",
"ViTriDiaLyDakMil": "The lake is located 67km from the center of Gia Nghia city to the northeast with an area of ​​more than 10km with an open surface area of ​​108ha and the deepest place reaching 17m. Explaining the special name, locals said, this name comes from the location of the lake. Because it is located in the west of the town, many people have called it West Lake, which has become familiar, over time people add the town's name to form the name Tay Dak Mil lake as it is today.",
"CanhDep":"Beauty scene",
"CanhDepDakMil":"As the most beautiful lake in Dak Mil town, it is not difficult to understand that West Lake is a familiar destination for tourists as well as locals, especially young people. The scenery at West Dak Mil lake is both beautiful and romantic, even though it is located in the middle of the city. From a distance, this lake is divided into two branches, hugging around the green coffee plantation, reminiscent of the image of a beautiful oasis. The winding roads or the rows of green trees around the lake also contribute to the poetic beauty of the lake.",
"GioiThieuDapW":"The unique flow and design of the W dam in Dak Nong make tourists excited and curious. This beautiful dam is one of the familiar check-in places for young people every season when the water rises.",
"LichSuDapW":"W Dak Nong Dam was built in 1999, with an area of ​​about 22 hectares to serve the needs of irrigation and water supply for the lives of local people. Although the original purpose of construction was just to prevent water and serve local life and production, with its unique design, this dam has become a favorite check-in point of local young people as well as tourists when coming to Dak Mil.",
"ViTriDiaLyDapW":"W Dam is located in Dak Sak village, Dak Mil district. to reach this place you just need to move to Duc Manh junction of Dak Sak village, then go through Nguyen Du school and enjoy the unique yet beautiful scence of Dam W.",
"CanhDepDapW":"This monumental dam possesses impressive beauty with large streams of water splashing on the spillways, creating an extremely impressive scene. The scenery here is as beautiful as any famous waterfall in Dak Nong, so it attracts more and more tourists to visit. You can check-in at W Dak Nong dam in many different locations from on the shore to the bottom of the spillway, the white foaming strips of water are the perfect background for you to freely pose and take pictures. ravishingly beautiful. With the unique beauty of W Dam as well as the love of tourists from all over the world, the site is being planned to become one of Dak Mil's tourist attractions."
}
VI.json:
{
"first_string": "Xin chào! Đây là tin nhắn đầu tiên. ",
"second_string": "Nếu hướng dẫn này hữu ích với bạn, hãy like và đăng ký Reso Coder 😉",
"titleHoTay": "Hồ Tây",
"titleDapW": "Đập W",
"titleNhaNgucDm": "Nhà ngục Đắk Mil",
"GioiThieu": "Giới Thiệu",
"GioiThieuHoTay": "Hồ Tây Đăk Mil là một điểm đến cực kỳ quen thuộc với người dân tại thị trấn nhỏ Đắk Mil, không chỉ có vai trò điều hòa và tạo sự cân bằng về cảnh quan cho thị trấn xinh đẹp này mà đây còn là điểm đến thu hút các bạn trẻ và du khách bởi khung cảnh thơ mộng và yên bình. Có dịp đến với thị trấn nhỏ Đăk Mil của tỉnh Đắk Nông, bạn đừng quên đến check-in tại điểm đến cực hot này nhé. ",
"LichSu":"Lịch Sử",
"LichSuHoTay":"Hồ Tây ở Đăk Mil là hồ nước bán nhân tạo, được hình thành từ những năm 1940. Ban đầu hồ được thực dân Pháp quy hoạch để trữ nước phục vụ cho dự án trồng cafe tại Đắk Nông. Đến năm 1982, thị trấn tiếp tục đầu tư mở rộng mặt hồ để phục vụ tốt hơn nhu cầu tưới tiêu của người dân và đồng thời trở thành nơi dung chứa nước từ các mạch nước ngầm. Cũng chính vì nguyên nhân này mà nước tại đây luôn trong xanh quanh năm. ",
"ViTriDiaLy":"Vị Trí Địa Lý",
"ViTriDiaLyDakMil":"Hồ nằm cách trung tâm của thành phố Gia Nghĩa 67km về hướng Đông Bắc với diện tích hơn 10km với diện tích mặt thoáng là 108ha và nơi sâu nhất đạt 17m. Lý giải về cái tên đặc biệt người dân địa phương cho biết, tên gọi này xuất phát từ vị trí của hồ. Do nằm ở phía Tây của thị trấn nên nhiều người đã gọi thành hồ Tây, lâu thành quen, theo thời gian người ta gắn thêm tên thị trấn hình thành nên tên gọi hồ Tây Đăk Mil như hiện tại. ",
"CanhDep":"Cảnh Đẹp",
"CanhDepDakMil":"Là hồ nước đẹp bậc nhất thị trấn Đăk Mil, nên không khó hiểu khi hồ Tây chính là điểm đến quen thuộc của du khách cũng như người dân địa phương, nhất là với các bạn trẻ. Khung cảnh ở hồ Tây Đăk Mil vừa đẹp lãng mạn lại có chút gì đó hoang sơ dù nằm giữa phố thị. Nhìn từ xa hồ nước này được chia thành hai nhánh, ôm quanh đồi trồng cafe xanh mướt khiến ta liên tưởng đến hình ảnh của một ốc đảo xinh tươi. Những con đường uốn lượn hay những hàng cây xanh mướt xung quanh hồ cũng góp phần tạo nên vẻ đẹp thơ mộng của hồ.",
"GioiThieuDapW":"Dòng chảy và thiết kế độc lạ của đập W ở Đăk Nông khiến các tín đồ du lịch phấn khích lẫn tò mò. Đập nước tuyệt đẹp này là một trong những địa điểm check-in quen thuộc của các bạn trẻ mỗi mùa nước lên. ",
"LichSuDapW":"Đập W Đăk Nông được xây dựng từ năm 1999, với diện tích khoảng 22 ha để phục vụ cho nhu cầu tưới tiêu, cung cấp nước phục vụ đời sống của đồng bào địa phương. Mặc dù mục đích xây dựng ban đầu chỉ là để ngăn nước và phục vụ đời sống và sản xuất tại địa phương, tuy nhiên với thiết kế độc đáo, đập nước này đã trở thành điểm check-in yêu thích của các bạn trẻ địa phương cũng như du khách khi đến với Đăk Mil.",
"ViTriDiaLyDapW":"Đập W Đăk Nông tọa lạc tại xã Đăk Săk, huyện Đăk Mil, để đến được địa điểm này bạn chỉ cần di chuyển đến ngã 3 Đức Mạnh của xã Đăk Săk sau đó đi qua ngôi trường Nguyên Du rồi rẽ vào đập W.",
"CanhDepDapW":"Đập nước hoành tráng này sở hữu vẻ đẹp ấn tượng với những luồng nước lớn bắn tung tóe trên các trụ tràn, tạo nên khung cảnh vô cùng ấn tượng. Khung cảnh ở đây đẹp không kém bất cứ thác nước nổi tiếng nào tại Đăk Nông, nên ngày càng thu hút du khách tìm đến thăm quan. Bạn có thể check-in tại đập W Đăk Nông ở nhiều vị trí khác nhau từ trên bờ đến phía dưới đập tràn, những dải nước tung bọt trắng xóa chính là background hoàn hảo để bạn thỏa sức tạo dáng và thu về những bức ảnh đẹp mê hồn. Trước vẻ đẹp độc đáo của đập W cũng như sự yêu thích của du khách thập phương, địa điểm đang được quy hoạch để trở thành một trong những điểm du lịch của Đắk Mil. "
}
TayLake,DamW,DakMilPrison.dart:
import 'package:flutter/material.dart';
import 'app_localizations.dart';
class DamW extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.translate("titleDapW")),
),
body: Scrollbar(
isAlwaysShown: true,
showTrackOnHover: true,
child: SingleChildScrollView(
child: Column(
children: [
printImage("",
170.0),
printTitle(
AppLocalizations.of(context)!.translate("GioiThieu")),
printText(
AppLocalizations.of(context)!.translate("GioiThieuDapW")),
printImage("",
180.0),
printTitle(
AppLocalizations.of(context)!.translate("LichSu")),
printText(
AppLocalizations.of(context)!.translate("LichSuDapW")),
printImage("",
180.0),
printTitle(
AppLocalizations.of(context)!.translate("ViTriDiaLy")),
printText(
AppLocalizations.of(context)!.translate("ViTriDiaLyDapW")),
printImage(
"",
180.0),
printTitle(AppLocalizations.of(context)!.translate("CanhDep")),
printText(
AppLocalizations.of(context)!.translate("CanhDepDapW")),
],
))));
}
Widget printTitle(String text) {
return Container(
child: Text(text,
style: TextStyle(fontSize: 20, color: Colors.grey.shade800)),
padding: EdgeInsets.fromLTRB(0, 50, 50, 0));
}
Widget printText(String text) {
return Container(
child: Text(text,
style: TextStyle(
fontSize: 15,
color: Colors.grey.shade600,
fontFamily: 'Manrope')),
padding: EdgeInsets.fromLTRB(50, 25, 50, 25));
}
Widget printImage(String url, double height) {
return Container(
constraints: BoxConstraints.tightFor(height: height),
child: Image.network(url, fit: BoxFit.fitWidth),
);
}
}
Note:
I have already imported all the package needed,
In fact, TayLake.dart;DamW.dart and DakMilPrison.dart are three different file, but they are basiclly the same format so I just put one of them there. (If you want the code, tell me down below :>)
The localization system is not the exact same as the tutorial, I don't know why but the tutorial is not including null safety so I add a lot of "!" and "?" to fix it (may be that's the reason).
To some up the debugging process:
hard code a different language to check whether the translations are correctly registered
MaterialApp(
locale: Locale('vi'),
...
)
If this works, make sure the language is correctly configured for the system. for Chrome:
Open the Chrome preferences
Search for "Languages"
Find "Order languages based on your preference"
Sort the preferred language to the top.

Sphinx 3.1.1. DocStore seems to fail

I have recently upgraded to Sphinx 3.1.1. to be able to use DocStore. For my index I use the following configuration:
index RT_TEST
{
type = rt
path = /mnt/data001/RT_TEST
rt_field = Name
rt_field = Extension
rt_field = Content
rt_field = Tags
rt_attr_uint = Reference
rt_attr_uint = FileSize
rt_attr_uint = LastModified
rt_attr_uint = LastModifiedYear
rt_attr_uint = LastModifiedMonth
rt_attr_uint = LastModifiedDay
stored_fields = Content
rt_mem_limit = 1024M
charset_table = A..Z, a..z, 0..9, _, ;, %
ondisk_attrs = pool
}
searchd
{
listen = 9306:mysql41
log = /var/sphinx/searchd.log
read_timeout = 5
max_children = 30
pid_file = /var/run/searchd.pid
max_packet_size = 128M
binlog_path = /mnt/data001
}
Important to realize is that I insert encrypted content meeting the charset_table directive of my index configuration. Still, the insert fails since the queried value differs from the inserted value...
For instance, the following insert statement:
INSERT INTO RT_TEST(id, Name, Extension, Content, Tags, Reference, FileSize, LastModified, LastModifiedYear, LastModifiedMonth, LastModifiedDay) VALUES(1774, 'DwQ2vTcCx1lfeDU% DwQ0tywFxw%% DAssrSQU2w%% VFpz7WtXmnUHLGt2', '7A5A5Q', 'FAUsvCA% FAUsvCA% BA8s Fg8sqy4D BA8s9jcJzE5TXysiVnBiOjr8YRE% AB0% DwQ2vTcCx1lfeDU% DwQ0tywFxw%% DAssrSQU2w%% VFpz7Q%% DgM% AgMjtiQ% Ag84vQ%% UFo% CwMsrTEDzA%% DgsmvCAI EQ8% CAMnrA%% AgUtqg%% CwUlvSs% BA8uuTYSx0Q% EA8woioDyQ%% EAss Eg8wvTYH AQ81vSAV1g%% CQc% Aw8s BwssrCQK Dx4ntTY% Eg8% BQInuy4DzA%% Cwsjqg%% AgM2 EQsx Cw82 Aw8s FA8mvSs% Agsjqg%% CQQ4vQ%% FQE3 Ags2uQ%% CAMnrA%% BQUwqiAF1g%% Cw8nqg%% DwQ% Dg82 FRMxrCADzw%% FR4ttiE% HAMotg%% Axg% EAUtqg%% Aw8s Fgsjqg%% CRgmvTcV Ag84vQ%% Dx4ntTY% FRMxrCALw15fbDgv CAMnrA%% AQ8xvSkDwV5Teikj DwE% HAsu Axg0tyoU HAUwvyAI Ags2 Ag84vQ%% CRo% Ag8% DwQ0tywFxw%% EAss AA8gqjAH0EM% AQ8hqiACy15Teikj AQsjrA%% EQUwvCAI HAsu DwQ% Ag8% BAMotCQBxw%% EAsx CRolv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gc% EgU% AgMjtiQ% AgMntCwV0U9Y FR8gsiAF1g%% AB0% DwQ2vTcCx1lfeDU% DwQ0tywFxw%% DAssrSQU2w%% VFpz7Q%% DgM% AgMjtiQ% AgU% HwU3 Dgs0vQ%% Bw%% FQInvTE% EgIjrA%% FQItrzY% EgIn EAsx BQIjqiID0Q%% EgInoQ%% Bxgn CA8jqikf AgU3uikD EQIjrA%% EgInoQ%% Exk3uSkK2w%% Bxgn Eg8wvTYH FQsgtyk% Fh8wuy0H0UNYeA%% BxkxtyYPw15T Ul5y9XdSmgcGLmx; Hll06w%% ABgttQ%% AgMjtiQ% AgMntCwV0U9Y AgMjtiRIxkNTczI0S2ZnH51RoVnYBIbuBLY% FQ8srA%% CwUsvCQf AA8gqjAH0FM% V1w% VFpz7Q%% XlBx7w%% Bwc% EgU% Eg8wvTYH FQsgtyk% FR8gsiAF1g%% DwQ2vTcCx1lfeDU% DwQ0tywFxw%% DAssrSQU2w%% VFpz7Q%% Ag8jqg%% Eg8wvTYH BQss HwU3 CQE% EgIn Bx42uSYOx04% FQInvTE% EgIjti4V DQMsvA%% FA8luTcC0Q%% Cw82 EBgrvSsCx0ZfdTAi ARgtvTEDzA%% AgMjtiQ% AgMntCwV0U9Y FQ8j ABgnsSIO1g%% DwcytzcS CRonqiQSzVg% FAUqtCwB CA8mvTcKw0RS BEQ0 EQ8ntiQ% VFpy BB8rtCEPzE0% EQ8ntiQ% VV5w EgU1vTc% Bw%% V1gktA%% VVpz6g%% CAA% FAU2rCAUxktb Eg8u VVs% V1o% VFI% VF8% VFhx AAs6 VVs% V1o% VFI% VF8% VF5w AgMjtiRIxkNTczI0S2ZnH51RoVnYBIbuBLY% ER019jcJykZfeHUkV24% FgYjuyA% CQw% DB8wsTYCy0lCdjQp EgIn CA82sCAUzktYeyg% FAU2rCAUxktb EhgjvCA% FA8lsTYSx1g% FAU2rCAUxktb CBhs6nFWmhMALWs% EgIn Ah82uy0% AAUwryQUxkNYeA%% BQUsvCwSy0VYbA%% DwQ% EgIn Cgs2vTYS EA8wqywJzA%% Ag8ytzYP1k9S BBM% AA8svT0% Bx4% EgIn FA8lsTYS0FM% CQw% EgIn AgMxrDcPwV4% BQU3qjE% Bx4% FAU2rCAUxktb FQIjtCk% BxoytDw% EgIn BQUsvCwSy0VYbA%% EQMutA%% BA8% FQ8srA%% EgU% HwU3 CQQ% FA8zrSAV1g%% FhgrriwKx01Te3QkV21vNrJfYupkLoM% DwQktzcLw15fcDU% Cws7 BA8% BQUsrCQPzE9S DwQ% EgIrqw%% Cw8xqyQBxw%% BwQm FhgtrCAF1k9S BBM% Bw%% FhgtviAV0UNZcTor FhgrriwKx01T CRg% EQItqyA% AgMxuykJ0V9Eeg%% BBM% Bw%% Cgs1 Dww% HwU3 Bxgn CAU2 EgIn Bw4mqiAV0U9T DwQmsSYH1k9S DwQ% EgIrqw%% Cw8xqyQBxw%% HwU3 Cws7 CAU2 BQUyoQ%% CRg% Ag8usTMD0A%% EgIrqw%% Cw8xqyQBxw%% EgU% BwQ7tysD DwQ% FR8hsA%% BQsxvQ%% HwU3 FQItrSkC Ag8xrDcJ2w%% EgIrqw%% Cw8xqyQBxw%% BwQm CAU2sSMf Exk% DwcvvSEPw15TcyI% DwQ2vTcIx14% A0cvuSwK CA8rrC0D0A%% AR8jqiQI1k9TbA%% EgIn BQUsviwCx0RCdjorUXdw CAUw EgIn DwQ2vSIUy15P CRg% FhgtqCAU FA8hvSwW1g%% CQw% EgIn Cw8xqyQBx1k% FQ8srA%% FKn0sCkPxQ%% AgUnqw%% CAU2 BxkxrSgD BwQ7 CgMjuiwKy15P AAUw EgItqyA% BQMwuzAL0V5XcTgiSw%% Dww% EgIn Bw4mqiAV0U9T CQw% EgIrqw%% Cw8xqyQBxw%% AgUnqw%% CAU2 BQUsqyAI1g%% EgU% EgIn Exkn CQw% DwQ2vTcIx14% A0cvuSwK BwQm Cw8xqyQBxw%% FA8htzcCy0RR FgYnuTYD CAU2sSMf Exk% DwcvvSEPw15TcyI% EAsx VFpz7Q%% Ags2rSg% CRgmvTcI10dbeik% FA82rTcI Bw4vsSs% CwMs FA82rTcI DwQgtzAIxg%% BQInuy4% EQswvS0J11lT CwMs FA82rTcI Fh82uTIH2w%% EQswvS0J11lT CwMs EgA6 CgsgvSkV FQE3 DgMxrCoU2w%% FR4tuy4% BQInuy4% EwQuvTYV Fg8sqy4D BwkhtzAI1ktUcz4% AAUw FgMhsw%% Axgwtzc% AQ8wtSQI2w%% CgsgvSkV BwcjoioI CgsgvSkV CwsrtDY% BwgtrTE% EwQptioRzA%% CRgmvTcV CRgmvTc% BQIjtiID0Q%% DwQ% CRgmvTc% Dg8jvA%% Ags2uQ%% Bw4mqiAV0Q%% CRgmvTc% BQIjtiID0Q%% DwQ% Dx4ntSkPzE8% Vg%% Dx4ntQ%% CgMsvQ%% CR82 CQw% FR4tuy4% Dx4ntQ%% CgMsvQ%% BQIjtiID EgIn FR4jrDAV CQw% Bw%% FR4tuy4% Dx4ntQ%% CR4qvTcV EQM2sA%% FA8vuTcN0Q%% FA8vuTcN0Q%% EQ8nsw%% VA%% U0couStLkx8% FFhw6n1elx0E V1o% V1o% UEcouSs% FR4tuy4% BQU3tjE% Eg8wvTYH UFo% CwsrtA%% Eg8wvTYH Cws% U0dz9XdWkx8% V1947X0% Cws% U0dz9XdWkx8% V1x46XQ% UUcouSs% VFhx6HxRlRI% VVo% VVo% VA%% CwsrtA%% EAMhsyw% AgM% UEdz9XdWkx8% V1J46nA% XkcouSs% VFhw4Xxemx8% Vw%% XkcouSs% VFhx6XVXkh0% VQ%% Vw%% X0couSs% VFhx6XVXkxo% VQ%% VQ%% X0couSs% VFhx6Hxekhw% Vw%% EQ8nsw%% VQ%% V1hvsiQIjxsD VFhx6H1UkBM% VVo% VVo% V18% V1lvsiQI VFhx6XVXlRw% VQ%% Vw%% V1lvsiQI VFhx6XVXkxI% Vw%% V1lvsiQI VFhx6XVXkx8% Vw%% V1lvsiQI VFhx6XVXkxg% VA%% Vw%% V1lvsiQ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V18% Uw%% VFtvsiQI FA82rTcIxU9ZezI0 V1o% V1o% Uw%% VFtvsiQI FA82rTcI10EGL2oqVQ%% V18% Ul8% V18% VFhvsiQI Ulpz6HFQlxM% UVJy CgUtqyA% CgUjvCwIxQ%% BQUsrCQPzE9E UFo% CwMsqw%% CQwksSYD UVhy CwMsqw%% EQswvS0J11lT VFlvsiQI VFhx6nFWlR4% Ug%% VFlvsiQI VFhx6nZVlh4% VQ%% VFlvsiQI VFhx6nVfkRo% VQ%% VFlvsiQI VFhx6nZVlhs% VQ%% VFlvsiQI VFhx6nZVkR8% Uw%% VFlvsiQI VFhx6nBflx4% Ug%% VFlvsiQI VFhx6nNVkhI% Vw%% VFlvsiQI VFhx6nVfkxw% Ug%% VFlvsiQI VFhx6XJVkhMZLGtyFzc6bg%% Vw%% VFlvsiQI FFhw6nNTkBgC Ul8% VVo% V18% EQ8nsw%% Vl8% VFxvsiQI Ulpz6HFQlxI% UVJy CgUtqyA% CgUjvCwIxQ%% BQUsrCQPzE9E UFo% CwMsqw%% CQwksSYD UVhy CwMsqw%% EQswvS0J11lT VF1vsiQI VFhx6nNVkhw% VQ%% VQ%% VF1vsiQI VFhx6nBflRI% VA%% VA%% VF1vsiQI VFhx6nxSmxM% Vw%% Vw%% VF1vsiQI VFhx6nBflBk% VA%% Vw%% VF1vsiQI VFhx6nBfkxw% VQ%% VF1vsiQI VFhx6nBRmxw% VFhx6nNVkh4% VA%% VF1vsiQI VFhx6nBflBg% VFhx6nNWlxk% VA%% VF1vsiQI VFhx6nBflB8% Vw%% VF1vsiQI VFhx6nNVkxo% Vw%% VF1vsiQI VFhx6nNVkhk% VFhx6nBflBo% VA%% VF1vsiQI VFhx6nNVkxs% Vw%% VF1vsiQI VFhx6nBflB0% VFhx6nNWlh8% VQ%% VF1vsiQI VFhx6nBflR0% VFhx6nBekB8% VA%% VF1vsiQI FAsvuXdRkhs% V1o% V1o% V1o% VF1vsiQI EwFy6HELzw%% V18% U1o% V1o% VF1vsiQI FAsvondRkhs% V1o% V18% V1o% VFJvsiQI VFhx6nNVkh8% VQ%% VFJvsiQI VFhx6nBfkxI% VQ%% DwQhtDACy0RR EgIrqw%% CgMsvQ%% DwQ0tywFx04% CQQ% VVpt6HQ% EQ8nsw%% Vlw% VUckvSc% VFhx63dQlh0% Xg%% Xg%% VUckvSc% VFhx63dRlR0% Vw%% Vw%% VUckvSc% VFhx63dQlhs% Vw%% Vw%% VUckvSc% VFhx63dRkBM% VA%% VA%% VUckvSc% VFhx63dRlRo% Vw%% Vw%% VUckvSc% VFhx63dRkRk% Vw%% Vw%% VUckvSc% VFhx63dQkRIdLWl0CzE;a7M% VA%% VUckvSc% VFhx63dRlBIdLWl0CzE_azw% VA%% VUckvSc% VFhx63dRlxw% Vw%% VUckvSc% VFhx63FUkRo% Vw%% VUckvSc% VFhx63dRlxk% Vw%% VUckvSc% VFhx63dQlxodLWl0CzE_bkE% VA%% UkckvSc% VFhx63FUkRM% Ug%% UkckvSc% VFhx63ZelxI% Ug%% UkckvSc% VFhx63dQlh4% VQ%% UkckvSc% VFhx63dQlh8% VQ%% UkckvSc% FA82uykPwUJP V1o% V1o% V1o% UkckvSc% FA826HFWkBsD V1o% VV8% V1o% U0ckvSc% FA826ndVkxoOJmw% VFo% U1o% U1o% UEckvSc% VFhx63JSlB8% Ug%% UEckvSc% VFhx631Vlx0% Ug%% UEckvSc% VFhx631Vlx8dLWl0CzQ9ae8% Ug%% UEckvSc% VFhx631VlBo% Ug%% UEckvSc% VFhx63xXkR0% Ug%% UEckvSc% VFhx631VlxM% Ug%% UEckvSc% VFhx631VlB4% VA%% UEckvSc% VFhx631Vlxw% Ug%% UEckvSc% VFhx63xXkRw% Ug%% UEckvSc% VFhx7HRRkBk% VQ%% UEckvSc% VFhx7HRRkB0% VA%% UEckvSc% VFhx7HRRkB8% Uw%% UEckvSc% FA826ndVkxoOJmw% Ul8% Ulo% UFo% EQ8nsw%% UQ%% V1pvviAE VFhx7HRSlxw% UQ%% UQ%% V1p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w CgsgvSk% FA8gvSYFww%% BxoyvSkJ VA%% CwMsrTED0Q%% Fg8w CgsgvSk% FA8gvSYFww%% BxoyvSkJ FA8gvSYFww%% BxoyvSkJ VA%% CwMsrTED0Q%% Fg8w CgsgvSk% FQInvTFX EBgrvTYL Vw%% FgsutCASzktUejc% Dxk% FR4jtiEHw1hS', '', 11, 1021089, 1503999582, 2017, 8, 29);
Leads to the following query value when I query the value with: SELECT content FROM RT_TEST WHERE id=1774; I get the value:
FAUsvCA% FAUsvCA% BA8s Fg8sqy4D BA8s9jcJzE5TXysiVnBiOjr8YRE% AB0% Fg8sqy4D BQUvqCkHy0RC AAUwtQ%% EgIn DgUuvCwIxQ%% BQU% DgM% Ag8jtg%% Dw%% EgItrSIO1g%% Dw%% BwYwvSQC2w%% AQs0vQ%% HwU3 BwQ% BwQxryAU CQQ% EgIrqw%% BQUvqCkHy0RC BB82 BQsstioS AAMsvA%% BwQ7 AwcjsSk% ABgttQ%% CxM% FQMmvQ%% FQU% Bx4% AAMwqzE% CxM% BxottCoBy1BTbA%% EQ8% Dgs0vQ%% DwQ0vTYSy01Xaz4j EgIrqw%% BQUvqCkHy0RC BBM% BQInuy4PzE0% CR8w FgI7qywFw0Y% FR4tuy4% BwkhtzcCy0RR EgU% CR8w Bw4vsSsP0V5Efi8uTmY% FR4tuy4% AAUwrDAIw15TcyI% EgInqyA% AgU% Cws2uy0% BwYxtw%% EgIn CB8vuiAU CQw% BAU6vTY% EQIruy0% FQItrSkC Dgs0vQ%% BA8ntg%% FgMhsyAC AAUw EgIrqw%% FQIrqCgDzF5F AgUnqw%% Cws2uy0% EgIn CB8vuiAU CQw% BAU6vTY% EQ8% FQItrSkC Dgs0vQ%% BA8ntg%% FgMhsywIxQ%% BwkhtzcCy0RR EgU% EgIrqw%% DwQktzcLw15fcDU% Dw%% BQss CQQuoQ%% BQUsuykTxk8% EgIjrA%% EQ8% Dgs0vQ%% FQIrqDUDxg%% CR82 EgIn BQUwqiAF1g%% Fx8jtjEP1kNTbA%% AAUw EgIrqw%% FQIrqCgDzF4% FQU% Fg8sqy4D CAU2 BwkhtzAI1ktUcz4% DgUyvQ%% EgU% DwQktzcLx04% HwU3 FR8kviwFy09Yaw%% FA8luTcC0Q%% BA8s ABgttQ%% BwQsuQ%% AxMu BwQsuWsD20Z2djUzXXFtOsW2NhQOEHrd7KpL FQ8srA%% CwUsvCQf Cwswuy0% VVs% VFpz7A%% V1t46XA% Fgc% EgU% Ag8jtmsLzUVEehs1V2tlNsvV0Fr0 FAUqtCwB FgYn Fg8sqy4D FR8gsiAF1g%% Fg8sqy4D BQUvqCkHy0RC AAUwtQ%% EgIn DgUuvCwIxQ%% BQU% Ag8jqg%% Ag8jtg%% Dw%% Ehg3qzE% EgIrqw%% AwcjsSk% AAMsvDY% HwU3 EQ8utA%% FgYnuTYD AAMsvA%% Bx42uSYOx04% Fg8sqy4D BQUvqCkHy0RC AAUwtQ%% ABgttQ%% EgIn DgUuvCwIxQ%% BQU% AAUw Bw%% FQItqjEHxU8% BA8xrA%% FA8luTcC0Q%% BwQsuQ%% AxMu DwQ2vTcIw15fcDUmVA%% BR8xrCoLx1g% FQ8wriwFxw%% Eg8u Xlpy UV11 UlN77Q%% AxI2 V1x3
As you can see, the queried value doesn't equal the inserted content-value. How is this possible and what am I doing wrong?

Babel preset env not targeting correct env

I may be confused as to what babel-preset-env actually does. My assumption is that it would transpile my code for my targeted browsers including any necessary polyfills. This doesn't appear to be the case in my code though...
My code:
import "babel-polyfill"
...
var k = Object.values({ x: 's' });
My babel settings:
"presets": [
[ "env", {
"useBuiltIns": true,
"targets": {
"browsers": ["last 2 versions", "IE 10"]
}
}]
]
The transpiled code still contains Object.values and IE 10 dies quietly (it does transpile - I can see the rest of the code changing - just seems to target wrong).
Package.json (some of these imports are not in use):
"core-js": "^2.5.1",
"opentype.js": "^0.7.2",
"svg.draggable.js": "^2.2.1",
"svg.js": "^2.6.3",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-latest": "^6.24.1",
"babel-register": "^6.24.1",
"clean-webpack-plugin": "^0.1.16",
"compression-webpack-plugin": "^1.0.0",
"copy-webpack-plugin": "^4.0.1",
"imports-loader": "^0.7.1",
"mocha": "^3.5.0",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.8.2",
"webpack-merge": "^4.1.0"
babel-preset-env in its default state only handles converting syntax, not polyfilling standard library functionality.
Sounds like you'll want useBuiltins: true in your config. You'll also need to follow the other instructions there by installing core-js and adding an import for babel-polyfill.
Alternatively you can just load babel-polyfill itself and not rely on babel-preset-env at all.

Unable to get arrow function to work

I am trying to upgrade to es6 for an existing project with Babel. My package.json contains the babel plugins:
"devDependencies": {
"babel-cli": "^6.8.0",
"babel-core": "^6.0.0",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"babel-preset-stage-2": "^6.5.0",
"babel-register": "^6.8.0",
"copy-webpack-plugin": "^2.1.3",
"css-loader": "^0.23.1",
"eslint": "^2.9.0",
"material-ui": "^0.15.0",
"node-sass": "^3.5.3",
"react-hot-loader": "^1.3.0",
"sass-loader": "^3.2.0",
"style-loader": "^0.13.1",
"webpack": "^1.13.0",
"webpack-dev-server": "^1.12.1"
My .babelrc file the following:
{
"presets": ["es2015", "stage-1", "react"],
"plugins": [
"transform-es2015-arrow-functions",
"transform-class-properties"
]
}
And my webpack file contains the following:
```
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel-loader?presets[]=react,presets[]=es2015,presets[]=stage-2']
},
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
}
]}
```
And I run my node app with the following command:
cp views/index.html public/index.html && NODE_ENV=development webpack && npm run webpack-dev-server"
I am using a toggle function with material-ui in order to get Drawer component triggered by a hamburger menu in the Appbar component.
The Toggle functions are as follows (as per documentation)
```
handleToggle = () => this.setState({open: !this.state.open});
handleClose = () => this.setState({open: false});
``
However, whenever I run this I get the following error:
Unexpected token (29:16)
27 |
28 |
> 29 | handleToggle () => this.setState({open: !this.state.open});
| ^
30 |
If I change the function from arrow to a more old-school approach I can get it to work i.e.
handleToggle() {
this.setState({open: !this.state.open});
alert("handleToggle clicked");
}
However, I do not want to have to customise every component in material-ui in order to enable it to be backwards compatible. How do I upgrade my code without getting errors?

Hibernate search hanging with large amount of entities

I have database of geonames (more than 8 000 000) entities, which are indexed by hibernate search.
I also have users and geonames associated with them. When I try to search for users, webapp hangs and not responding anymore and shutting down Tomcat doesn't terminates it's Java process.
According to logs, transaction starts and doesn't finish. And what is strange: on laptop with same Postgresql version this works fine but hangs on virtualbox server with same 4 GB RAM.
Also while hanging there were enough free memory space, so the problem is not in that. What could be the reason of it?
My configuration:
postgresql 9.3.4
postgis 2.1.1
hibernate search 4.2
Laptop:
arch-linux x64,
virtualbox server:
ubuntu server 12.10
update: I realized that it creashes on spatial sorting, but there's no same error with another entity having the same assosiations with geonames. Here's error log:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space
at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.apache.lucene.util.collections.IntToDoubleMap.(IntToDoubleMap.java:226)
at org.apache.lucene.util.collections.IntToDoubleMap.grow(IntToDoubleMap.java:418)
at org.apache.lucene.util.collections.IntToDoubleMap.put(IntToDoubleMap.java:492)
at org.hibernate.search.spatial.impl.DistanceComparator.setNextReader(DistanceComparator.java:78)
at org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:95)
at org.hibernate.search.query.collector.impl.MapFieldCacheCollectorImpl.setNextReader(MapFieldCacheCollectorImpl.java:64)
at org.hibernate.search.query.collector.impl.TwoWayTransformingFieldCacheCollector.setNextReader(TwoWayTransformingFieldCacheCollector.java:59)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:576)
at org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:243)
at org.hibernate.search.query.engine.impl.QueryHits.(QueryHits.java:144)
at org.hibernate.search.query.engine.impl.HSQueryImpl.getQueryHits(HSQueryImpl.java:457)
at org.hibernate.search.query.engine.impl.HSQueryImpl.queryEntityInfos(HSQueryImpl.java:254)
at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.list(FullTextQueryImpl.java:209)
at ru.budetsdelano.startup.server.dao.impl.UserServiceImpl.findPerformers(UserServiceImpl.java:304)
at ru.budetsdelano.startup.server.dao.impl.UserServiceImpl$$FastClassByCGLIB$$a2118199.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at ru.budetsdelano.startup.server.dao.impl.UserServiceImpl$$EnhancerByCGLIB$$4966a48e.findPerformers()
at ru.budetsdelano.startup.server.controller.json.JsonSearchForPerformersController.searchFreePerformers(JsonSearchForPerformersController.java:70)
at ru.budetsdelano.startup.server.controller.json.JsonSearchForPerformersController$$FastClassByCGLIB$$edd7b285.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
update: here is search method:
FullTextSession fullTextSession = Search.getFullTextSession(sessionFactory.getCurrentSession());
QueryBuilder queryBuilder =fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(User.class).get();
org.apache.lucene.search.Query spatialQuery =queryBuilder.spatial().onCoordinates("pl").within(50000, Unit.KM).ofLatitude(latitude).andLongitude(longtitude).createQuery();
org.apache.lucene.search.Query isPerformerQuery = queryBuilder.keyword().onField("performer").matching(true).createQuery();
org.apache.lucene.search.Query nameQuery = ((!keywords.equals("") && (keywords != null))) ? queryBuilder.phrase().withSlop(10).onField("name").sentence(keywords).createQuery() : null;
org.apache.lucene.search.Query geonameIdQuery = geonameid != null ? queryBuilder.keyword().onField("city.geonameid").matching(geonameid).createQuery(): null ;
org.apache.lucene.search.Query profileQuery = (profile != null)? queryBuilder.keyword().onField("profiles_string").matching(profile).createQuery() : null;
org.apache.lucene.search.Query minimalBudgetQuery = queryBuilder.range().onField("minimal_budget").from(minimalBudget != null ? minimalBudget : 0L).to(maximumBudget != null ? maximumBudget :Long.MAX_VALUE).createQuery();
org.apache.lucene.search.Query minimalRatingQuery = minimalRating!= null ? queryBuilder.range().onField("task_rate").from(Double.valueOf(minimalRating)).to(Double.valueOf(5)).createQuery() : null;
org.apache.lucene.search.Query isOnlineQuery = (onlineOnly == true) ? queryBuilder.keyword().onField("online").matching(true).createQuery() : null;
org.apache.lucene.search.Query freeOnlyQuery = (freeOnly == true) ? queryBuilder.keyword().onField("active_tasks_count").matching(0).createQuery() : null;
BooleanJunction total = queryBuilder.bool().must(isPerformerQuery).must(minimalBudgetQuery).must(spatialQuery);
if (profileQuery != null) {
total = total.must(profileQuery);
}
if (nameQuery != null) {
total = total.must(nameQuery);
}
if (isOnlineQuery != null) {
total = total.must(isOnlineQuery);
}
if (freeOnlyQuery != null) {
total = total.must(freeOnlyQuery);
}
if (geonameIdQuery!=null) {
total = total.must(geonameIdQuery);
}
else if (minimalRatingQuery != null) {
total = total.must(minimalRatingQuery);
}
org.apache.lucene.search.Query totalQuery = total.createQuery();
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(totalQuery);
//fullTextQuery.setSpatialParameters(latitude,longtitude,"place");
if (orderType == User.OrderType.distance) {
Sort distanceSort = new Sort(new DistanceSortField(latitude,longtitude,"pl"));
fullTextQuery.setSort(distanceSort);
}
else if (orderType == User.OrderType.minimal_budget) {
SortField sortField = new SortField("minimal_budget",SortField.LONG,reverse);
fullTextQuery.setSort(new Sort(sortField));
}
else if (orderType == User.OrderType.rating) {
SortField sortField = new SortField("task_rate",SortField.DOUBLE,reverse);
fullTextQuery.setSort(new Sort(sortField));
}
fullTextQuery.setFirstResult(from);
fullTextQuery.setMaxResults(quantity);
return (List)fullTextQuery.list();