Skip to content

Commit

Permalink
Fixes issue signaled in #182: mecab was still required.
Browse files Browse the repository at this point in the history
Fixes many small parts of the code not collaborating with each other.
  • Loading branch information
HugoFara committed Jan 5, 2024
1 parent c18e295 commit 261e7a8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion api.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function readingConfiguration($get_req): array
*/
function get_phonetic_reading($get_req): array
{
if (array_key_exists("lgid", $get_req)) {
if (array_key_exists("lang_id", $get_req)) {
$data = phoneticReading($get_req['text'], $get_req['lang_id']);
} else {
$data = phonetic_reading($get_req['text'], $get_req['lang']);
Expand Down
6 changes: 3 additions & 3 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ after solution display ([#159](https://github.com/HugoFara/lwt/issues/159)).
* Database:
* Database creation and migration is now handled directly in SQL, for a safer
behavior.
* You do no longer need to give to LWT SYSTEM_VARIABLES_ADMIN for text reparsing. (new function `checkTextWithExpressions`) ([#167](https://github.com/HugoFara/lwt/issues/167)). It is still necessary for words import.
* You do no longer need to give to LWT SYSTEM_VARIABLES_ADMIN for text reparsing. (new function `checkExpressions`) ([#167](https://github.com/HugoFara/lwt/issues/167)). It is still necessary for words import.
* Docker changes:
* By default, the images now runs at localhot/lwt and no longer in the
root folder ([installer #4](https://github.com/HugoFara/lwt-docker-installer/pull/4)
Expand All @@ -77,8 +77,6 @@ behavior.
Solves [#129](https://github.com/HugoFara/lwt/issues/129), thanks to the help of PR
[#168](https://github.com/HugoFara/lwt/pull/168).
* Text reading position was not working consistently when adding several known words.
* Japanese was always requiring MeCab for TTS, even if it was not used
([#155](https://github.com/HugoFara/lwt/pull/155)).
* Multi-words:
* Tooltip was not properly saved ([#170](https://github.com/HugoFara/lwt/pull/170)).
* Translation may be escaped two times ([#170](https://github.com/HugoFara/lwt/pull/170)).
Expand All @@ -92,6 +90,8 @@ Solves [#129](https://github.com/HugoFara/lwt/issues/129), thanks to the help of
* Parsing Japanese texts with MeCab was creating warnings when the text was not
finishing by a punctation mark.
* Multi-words were not saved with MeCab parsing on Japanese.
* Japanese was always requiring MeCab for TTS, even if it was not used
([#155](https://github.com/HugoFara/lwt/pull/155)) and [#182](https://github.com/HugoFara/lwt/pull/182).
* On word review (test):
* the space keyboard shortcut may have been inoperating.
* On `api.php`, tests were always set to "multi-word" due to a missing variable
Expand Down
6 changes: 3 additions & 3 deletions docs/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ <h4>Changed</h4>
<ul>
<li>Database creation and migration is now handled directly in SQL, for a safer
behavior.</li>
<li>You do no longer need to give to LWT SYSTEM_VARIABLES_ADMIN for text reparsing. (new function <code>checkTextWithExpressions</code>) (<a href="https://github.com/HugoFara/lwt/issues/167">#167</a>). It is still necessary for words import.</li>
<li>You do no longer need to give to LWT SYSTEM_VARIABLES_ADMIN for text reparsing. (new function <code>checkExpressions</code>) (<a href="https://github.com/HugoFara/lwt/issues/167">#167</a>). It is still necessary for words import.</li>
</ul>
</li>
<li>Docker changes:
Expand All @@ -2324,8 +2324,6 @@ <h4>Fixed</h4>
Solves <a href="https://github.com/HugoFara/lwt/issues/129">#129</a>, thanks to the help of PR
<a href="https://github.com/HugoFara/lwt/pull/168">#168</a>.</li>
<li>Text reading position was not working consistently when adding several known words.</li>
<li>Japanese was always requiring MeCab for TTS, even if it was not used
(<a href="https://github.com/HugoFara/lwt/pull/155">#155</a>).</li>
<li>Multi-words:
<ul>
<li>Tooltip was not properly saved (<a href="https://github.com/HugoFara/lwt/pull/170">#170</a>).</li>
Expand All @@ -2343,6 +2341,8 @@ <h4>Fixed</h4>
<li>Parsing Japanese texts with MeCab was creating warnings when the text was not
finishing by a punctation mark.</li>
<li>Multi-words were not saved with MeCab parsing on Japanese.</li>
<li>Japanese was always requiring MeCab for TTS, even if it was not used
(<a href="https://github.com/HugoFara/lwt/pull/155">#155</a>) and <a href="https://github.com/HugoFara/lwt/pull/182">#182</a>.</li>
</ul>
</li>
<li>On word review (test):
Expand Down
2 changes: 1 addition & 1 deletion inc/session_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -3644,7 +3644,7 @@ function phoneticReading($text, $lgid)
{
global $tbpref;
$sentence_split = get_first_value(
"SELECT LgRegexpSplitSentences AS value FROM {$tbpref}languages
"SELECT LgRegexpWordCharacters AS value FROM {$tbpref}languages
WHERE LgID = $lgid"
);

Expand Down
4 changes: 2 additions & 2 deletions js/pgm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/js/user_interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ function getPhoneticText (text, lang) {
/**
* Get the phonetic version of a text, asynchronous.
*
* @param {string} text Text to convert to phonetics.
* @param {string|int} lang Language, either two letters code or four letters (BCP 47), or language ID
* @param {string} text Text to convert to phonetics.
* @param {string|number} lang Language, either two letters code or four letters (BCP 47), or language ID
*/
async function getPhoneticTextAsync (text, lang) {
const parameters = {
text: text
};
if (typeof lang == 'int') {
parameters.lgid = lang;
if (typeof lang == 'number') {
parameters.lang_id = lang;
} else {
parameters.lang = lang;
}
Expand Down Expand Up @@ -348,9 +348,9 @@ function speechDispatcher (term, lang_id) {
lgid: lang_id
},
function (data) {
if (data.readingMode == "direct" || data.readingMode == "internal") {
if (data.reading_mode == "direct" || data.reading_mode == "internal") {
const lang_settings = cookieTTSSettings(data.language);
if (data.readingMode == "direct") {
if (data.reading_mode == "direct") {
// No reparsing needed
readRawTextAloud(
term,
Expand All @@ -359,9 +359,9 @@ function speechDispatcher (term, lang_id) {
lang_settings.pitch,
lang_settings.voice
);
} else if (data.readingMode == "internal") {
} else if (data.reading_mode == "internal") {
// Server handled reparsing
getPhoneticTextAsync(text, lang_id)
getPhoneticTextAsync(term, parseInt(lang_id, 10))
.then(
function (reparsed_text) {
readRawTextAloud(
Expand All @@ -374,7 +374,7 @@ function speechDispatcher (term, lang_id) {
}
);
}
} else if (data.readingMode == "external") {
} else if (data.reading_mode == "external") {
// Use external API
readTextWithExternal(term, data.voiceApi, data.language);
}
Expand Down

0 comments on commit 261e7a8

Please sign in to comment.