Skip to content

Commit

Permalink
Removing nashorn dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jun 13, 2022
1 parent cfce4d4 commit 015eedc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
10 changes: 9 additions & 1 deletion src/main/java/org/luwrain/controls/EditSpellChecking.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

public class EditSpellChecking implements EditArea.ChangeListener
{
static private final String
LOG_COMPONENT = "spelling";

private final Luwrain luwrain;
private final SpellChecker checker = new SpellCheckerFactory().newChecker("ru");
public EditSpellChecking(Luwrain luwrain )
Expand All @@ -42,6 +45,7 @@ public EditSpellChecking(Luwrain luwrain )

private void check(EditArea editArea, SortedMap<Integer, String> text)
{
Log.debug(LOG_COMPONENT, "Checking lines: " + text.size());
final List<String> textLines = new ArrayList<>();
for(Map.Entry<Integer, String> e: text.entrySet())
textLines.add(e.getValue());
Expand All @@ -58,7 +62,11 @@ private void setResult(EditArea editArea, SortedMap<Integer, String> text, List<
{
final int lineIndex = e.getKey().intValue();
lines.setLineMarks(lineIndex, new DefaultLineMarks.Builder(lines.getLineMarks(lineIndex)).addAll(marks.get(index)).build());
index++;

Log.debug(LOG_COMPONENT, "Result for line " + lineIndex + ", " + String.valueOf(marks.get(index).size()) + " marks");
for(LineMarks.Mark m: marks.get(index))
Log.debug(LOG_COMPONENT, m.getMarkObject().toString());
index++;
}
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/luwrain/io/WebCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.luwrain.core.*;
import org.luwrain.popups.*;
import static org.luwrain.script.Hooks.*;
import static org.luwrain.script2.ScriptUtils.*;
import static org.luwrain.script.ScriptUtils.*;

public final class WebCommand implements Command
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/luwrain/io/WebSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.luwrain.core.*;
import org.luwrain.popups.*;
import static org.luwrain.script.Hooks.*;
import static org.luwrain.script2.ScriptUtils.*;
import static org.luwrain.script.ScriptUtils.*;

public final class WebSearch
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/luwrain/io/WebSearchResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.*;

import org.luwrain.core.*;
import static org.luwrain.script2.ScriptUtils.*;
import static org.luwrain.script.ScriptUtils.*;

public final class WebSearchResult
{
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/luwrain/nlp/SpellText.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

public class SpellText
{
static public final String
LOG_COMPONENT = "spelling";

final String text;
final List<Fragment> fragments = new ArrayList<>();
final List<SpellProblem> problems;
Expand All @@ -41,6 +44,7 @@ public SpellText(String[] text, SpellChecker checker)
{
this.text = text[0];
fragments.add(new Fragment(0, text[0].length()));
Log.debug(LOG_COMPONENT, "Checking '" + this.text + "'");
this.problems = checker.check(this.text);
return;
}
Expand All @@ -55,6 +59,7 @@ public SpellText(String[] text, SpellChecker checker)
this.text = new String(b);
if (fragments.size() != text.length)
throw new IllegalStateException("the fragments and text arrays have different length");
Log.debug(LOG_COMPONENT, "Checking '" + this.text + "'");
this.problems = checker.check(this.text);
}

Expand Down
17 changes: 1 addition & 16 deletions src/main/java/org/luwrain/nlp/ru/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
package org.luwrain.nlp.ru;

import org.luwrain.core.*;
import org.luwrain.script.*;

public final class Token extends EmptyHookObject
public final class Token
{
public enum Type {NUM, LATIN, CYRIL, SPACE, PUNC};

Expand Down Expand Up @@ -48,18 +47,4 @@ public String getText(String text)
{
return text;
}

@Override public Object getMember(String name)
{
NullCheck.notNull(name, "name");
switch(name)
{
case "type":
return type.toString().toLowerCase();
case "text":
return text;
default:
return super.getMember(name);
}
}
}

0 comments on commit 015eedc

Please sign in to comment.