Skip to content

Commit

Permalink
Merge pull request #12 from firm1/taskify_process
Browse files Browse the repository at this point in the history
Taskify process
  • Loading branch information
firm1 committed Feb 14, 2016
2 parents 90afea1 + 16e99e7 commit bfabfc7
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 149 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ sourceSets {
}

dependencies {
compile 'org.languagetool:languagetool-core:3.1',
'org.languagetool:language-fr:3.1',
compile 'org.languagetool:language-fr:3.1',
'org.apache.httpcomponents:httpclient:4.5.1',
'org.apache.httpcomponents:httpcore:4.4.3',
'org.apache.httpcomponents:fluent-hc:4.5.1',
Expand Down
22 changes: 15 additions & 7 deletions src/com/zestedesavoir/zestwriter/utils/Corrector.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,18 @@ private AnnotatedText makeAnnotatedText(String pseudoXml) {
return builder.build();
}

public String checkHtmlContent(String htmlContent) throws IOException {
public String checkHtmlContent(String htmlContent) {
AnnotatedText markup = makeAnnotatedText(htmlContent);
StringBuilder bf = new StringBuilder(htmlContent);

langTool.getAllActiveRules().stream().filter(rule -> rule instanceof SpellingCheckRule).forEach(rule -> ((SpellingCheckRule) rule).addIgnoreTokens(wordsToIgnore));

List<RuleMatch> matches = langTool.check(markup);
List<RuleMatch> matches = new ArrayList<>();
try {
matches = langTool.check(markup);
}
catch (Exception e) {
e.printStackTrace();
}
int offset = 0;
for (RuleMatch match : matches) {
String desc = "Note : " + match.getRule().getDescription();
Expand All @@ -167,13 +172,16 @@ public String checkHtmlContent(String htmlContent) throws IOException {
return bf.toString();
}

public String checkHtmlContentToText(String htmlContent, String source) throws IOException {
public String checkHtmlContentToText(String htmlContent, String source) {
AnnotatedText markup = makeAnnotatedText(htmlContent);
StringBuilder bf = new StringBuilder();

langTool.getAllActiveRules().stream().filter(rule -> rule instanceof SpellingCheckRule).forEach(rule -> ((SpellingCheckRule) rule).addIgnoreTokens(wordsToIgnore));

List<RuleMatch> matches = langTool.check(markup);
List<RuleMatch> matches = new ArrayList<>();
try {
matches = langTool.check(markup);
} catch (IOException e) {
e.printStackTrace();
}
int offset = 0;
for (RuleMatch match : matches) {
String txt = htmlContent.substring(match.getFromPos(), match.getToPos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public class Utilities {
public static Double round(double d, int decimalPlace) {
// see the Javadoc about why we use a String in the constructor
// http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(double)
BigDecimal bd = new BigDecimal(Double.toString(d));

BigDecimal bd = new BigDecimal(d);
bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
return bd.doubleValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public void HandleValidateButtonAction() {
WebEngine webEngine = renderView.getEngine();
webEngine.loadContent("<!doctype html><html lang='fr'><head><meta charset='utf-8'><base href='file://" + getClass().getResource(".").getPath() + "' /></head><body>" + result + "</body></html>");
webEngine.setUserStyleSheetLocation(getClass().getResource("content.css").toExternalForm());
} catch (DOMException | IOException e) {
} catch (DOMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Expand Down
Loading

0 comments on commit bfabfc7

Please sign in to comment.