-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d6bfff
commit f6cf189
Showing
8 changed files
with
28 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2019 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2021 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2019 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2021 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2019 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2021 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -19,18 +19,22 @@ | |
import java.util.*; | ||
|
||
import org.luwrain.core.*; | ||
import org.luwrain.core.script2.*; | ||
import org.luwrain.i18n.*; | ||
import org.luwrain.nlp.*; | ||
|
||
final class Lang extends LangBase | ||
{ | ||
private final ScriptCore scriptCore; | ||
private final SpeakableText speakableText; | ||
private final WordList wordsList = new WordList(); | ||
|
||
Lang(Luwrain luwrain, Map<String, String> staticStrings, Map<String, String> chars) | ||
{ | ||
super("ru", luwrain, staticStrings, chars); | ||
NullCheck.notNull(luwrain, "luwrain"); | ||
this.scriptCore = new ScriptCore(luwrain); | ||
|
||
this.speakableText = new SpeakableText(luwrain); | ||
this.wordsList.loadFromResource(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2019 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2021 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2019 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2021 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2020 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2021 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|
@@ -18,22 +18,24 @@ | |
|
||
import org.luwrain.core.*; | ||
import org.luwrain.core.Luwrain.SpeakableTextType; | ||
import org.luwrain.script.*; | ||
|
||
import org.luwrain.nlp.ru.*; | ||
import org.luwrain.script2.ScriptUtils; | ||
import org.luwrain.script.hooks.*; | ||
|
||
final class SpeakableText | ||
{ | ||
static private final String HOOK_NATURAL_PRE = "luwrain.i18n.ru.speakable.natural.pre"; | ||
static private final String HOOK_NATURAL = "luwrain.i18n.ru.speakable.natural"; | ||
static private final String HOOK_PROGRAMMING_PRE = "luwrain.i18n.ru.speech.programming.pre"; | ||
static private final String | ||
HOOK_NATURAL_PRE = "luwrain.i18n.ru.speakable.natural.pre", | ||
HOOK_NATURAL = "luwrain.i18n.ru.speakable.natural", | ||
HOOK_PROGRAMMING_PRE = "luwrain.i18n.ru.speech.programming.pre"; | ||
|
||
private final Luwrain luwrain; | ||
private final HookContainer hookContainer; | ||
|
||
SpeakableText(Luwrain luwrain) | ||
SpeakableText(HookContainer hookContainer) | ||
{ | ||
NullCheck.notNull(luwrain, "luwrain"); | ||
this.luwrain = luwrain; | ||
NullCheck.notNull(hookContainer, "hookContainer"); | ||
this.hookContainer = hookContainer; | ||
} | ||
|
||
String process(String text, SpeakableTextType type) | ||
|
@@ -45,7 +47,7 @@ String process(String text, SpeakableTextType type) | |
case NATURAL: | ||
return processNatural(text); | ||
case PROGRAMMING: | ||
return processProgramming(text); | ||
return processProgramming(text); | ||
default: | ||
return text; | ||
} | ||
|
@@ -54,22 +56,17 @@ String process(String text, SpeakableTextType type) | |
private String processNatural(String text) | ||
{ | ||
NullCheck.notNull(text, "text"); | ||
final SpeakableTextHook hook = new SpeakableTextHook(text); | ||
luwrain.runHooks(HOOK_NATURAL_PRE, hook); | ||
String t = hook.getText(); | ||
final String t = new TransformerHook(hookContainer).run(HOOK_NATURAL_PRE, text).toString(); | ||
final Token[] tokens = ReaderTokenizer.tokenize(t); | ||
final Object tokensRes = new ProviderHook(luwrain).run(HOOK_NATURAL, new Object[]{ScriptUtils.createArray(tokens)}); | ||
final Object tokensRes = new ProviderHook(hookContainer).run(HOOK_NATURAL, new Object[]{ScriptUtils.getArray(tokens)}); | ||
if (tokensRes != null && tokensRes.toString() != null) | ||
t = tokensRes.toString(); | ||
return tokensRes.toString(); | ||
return t; | ||
} | ||
|
||
private String processProgramming(String text) | ||
private String processProgramming(String text) | ||
{ | ||
NullCheck.notNull(text, "text"); | ||
final SpeakableTextHook hook = new SpeakableTextHook(text); | ||
luwrain.runHooks(HOOK_PROGRAMMING_PRE, hook); | ||
return hook.getText(); | ||
} | ||
|
||
return new TransformerHook(hookContainer).run(HOOK_PROGRAMMING_PRE, text).toString(); | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
ru/src/main/java/org/luwrain/i18n/ru/SpeakableTextHook.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
Copyright 2012-2019 Michael Pozhidaev <[email protected]> | ||
Copyright 2012-2021 Michael Pozhidaev <[email protected]> | ||
This file is part of LUWRAIN. | ||
|