mirror of
https://github.com/minimo-io/appticles.git
synced 2025-06-23 16:05:29 +00:00
add many new terms!
This commit is contained in:
parent
e8a92505ee
commit
9333077f7a
File diff suppressed because it is too large
Load Diff
@ -13,12 +13,17 @@ const App = Vue.createApp({
|
|||||||
methods:{
|
methods:{
|
||||||
matches(obj) {
|
matches(obj) {
|
||||||
const term = this.searchQuery.toLowerCase();
|
const term = this.searchQuery.toLowerCase();
|
||||||
return obj.title.toLowerCase().includes(term) || obj.description.toLowerCase().includes(term);
|
|
||||||
|
//return obj.t.toLowerCase().includes(term) || obj.d.toLowerCase().includes(term);
|
||||||
|
// search only on terms not descriptions for it not to be so messy
|
||||||
|
return obj.t.toLowerCase().includes(term);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async mounted(){
|
async mounted(){
|
||||||
const res = await fetch("https://cdn.jsdelivr.net/gh/minimo-io/appticles@v0.0.2-2/mo-lunfardo/data/lunfardo-dict-es.json");
|
const res = await fetch("https://cdn.jsdelivr.net/gh/minimo-io/appticles@v0.0.2-3/mo-lunfardo/data/lunfardo-dict-es.json");
|
||||||
|
// const res = await fetch("tools/dicc.json");
|
||||||
|
// const res = await fetch("data/lunfardo-dict-es.json");
|
||||||
this.wordsJson = await res.json();
|
this.wordsJson = await res.json();
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -35,7 +40,6 @@ const App = Vue.createApp({
|
|||||||
//return this.listValues.slice(0, 10);
|
//return this.listValues.slice(0, 10);
|
||||||
return this.listValues.slice(0, 50);
|
return this.listValues.slice(0, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.listValues
|
return this.listValues
|
||||||
.map((v) => {
|
.map((v) => {
|
||||||
if (this.matches(v)) {
|
if (this.matches(v)) {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<h2 v-if="!searchQuery">Algunos ejemplos de términos lunfardos</h2>
|
<h2 v-if="!searchQuery">Algunos ejemplos de términos lunfardos</h2>
|
||||||
<ul class="mt-4">
|
<ul class="mt-4">
|
||||||
<li v-for="(data, index) in filteredList"><strong>{{ data.title }}</strong>: {{ data.description }}</li>
|
<li v-for="(data, index) in filteredList"><strong>{{ data.t }}</strong>: {{ data.d }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
70
mo-lunfardo/tools/process.dart
Executable file
70
mo-lunfardo/tools/process.dart
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env dart
|
||||||
|
// process lunfardo dictionary raw file
|
||||||
|
// the process assumes the following structure: [term]:[description]
|
||||||
|
// https://github.com/minimo-io
|
||||||
|
|
||||||
|
// import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
main(List<String> args) {
|
||||||
|
var dir = Directory.current.path;
|
||||||
|
var p = Platform.script.path;
|
||||||
|
|
||||||
|
File('dicc.txt').readAsString().then((String contents) {
|
||||||
|
String contentsWithNoLines = contents.replaceAll("\r", "");
|
||||||
|
List<String> words = contentsWithNoLines.split("\n");
|
||||||
|
List<Map<String, String>> distilledTerms = []; // final string of terms
|
||||||
|
|
||||||
|
for (var word in words) {
|
||||||
|
var wordIndex = words.indexOf(word);
|
||||||
|
// if its only a number then its the page number from pdf and skip
|
||||||
|
if (isNumeric(word)) continue;
|
||||||
|
// capitalize
|
||||||
|
// word = word.capitalize();
|
||||||
|
|
||||||
|
if (word.contains(":")) {
|
||||||
|
List termList = word.split(":"); // [0]: term [1]: description
|
||||||
|
// add the term
|
||||||
|
distilledTerms.add({
|
||||||
|
't': termList[0],
|
||||||
|
'd': termList[1].toString().trim(),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// if the following line does not have an : then its not a new term
|
||||||
|
// but a part of the previus one.
|
||||||
|
// here we should add the term to the previous.
|
||||||
|
// word in this case is just a line with the rest of the description
|
||||||
|
// print(word);
|
||||||
|
// get last element of the terms array
|
||||||
|
Map<String, String> lastElement = distilledTerms.last;
|
||||||
|
int lastElementIndex = distilledTerms.indexOf(distilledTerms.last);
|
||||||
|
|
||||||
|
lastElement["d"] = lastElement["d"].toString() + " " + word;
|
||||||
|
|
||||||
|
// replace for the now complete term description
|
||||||
|
distilledTerms[lastElementIndex] = lastElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saveFile(json.encode(distilledTerms));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNumeric(String? s) {
|
||||||
|
if (s == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return double.tryParse(s) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveFile(String string) async {
|
||||||
|
File file = File(await "dicc.json");
|
||||||
|
file.writeAsString(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
extension StringExtension on String {
|
||||||
|
String capitalize() {
|
||||||
|
return "${this[0].toUpperCase()}${this.substring(1).toLowerCase()}";
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user