2016-10-03 5 views
0

LanguageTool Java API를 사용하여 텍스트 파일에있는 일부 맞춤법이 틀린 단어를 바로 잡으려고합니다.LanguageTool Java API를 사용하여 올바르게 맞춤법 검사를 수행 할 수 없습니다.

JLanguageTool langTool; 
String text = "I.- Any reference _in this Section to a panicular genus or species of an anirmgl, cxccpl where the context"; 
langTool = new JLanguageTool(Language.AMERICAN_ENGLISH); 
langTool.activateDefaultPatternRules(); 

List<RuleMatch> matches = langTool.check(text); 
for (RuleMatch match : matches) { 
      System.out.println("Potential error at line " + 
       match.getEndLine() + ", column " + 
       match.getColumn() + ": " + match.getMessage()); 
      System.out.println("Suggested correction: " + 
       match.getSuggestedReplacements()); 
} 

출력은 다음과 같다 - - LT 위키와 https://languagetool.org/를 통과 한 후 나는 몇 가지 예제 코드를 시도

예상 OUPUT

Potential error at line 0, column 19: Possible spelling mistake found 
Suggested correction: [Lin, Min, ain, bin, din, fin, gin, in, kin, min, pin, sin, tin, win, yin] 
Potential error at line 0, column 41: Possible spelling mistake found 
Suggested correction: [] 
Potential error at line 0, column 74: Possible spelling mistake found 
Suggested correction: [] 
Potential error at line 0, column 83: Possible spelling mistake found 
Suggested correction: [] 
- 내가 LT 독립형에서이 출력을 가지고

Starting check in English (American)... 
1. Line 1, column 19 
Message: Possible spelling mistake found (deactivate) 
Correction: in; win; bin; pin; tin; min; Lin; din; gin; kin; yin; ain; fin; sin; IN; In; Min; PIN 
Context: I.- Any reference _in this Section to a panicular genus or sp... 
2. Line 1, column 41 
Message: Possible spelling mistake found (deactivate) 
Correction: particular; funicular 
Context: ...I.- Any reference _in this Section to a panicular genus or species of an anirmgl, cxccpl ... 
3. Line 1, column 74 
Message: Possible spelling mistake found (deactivate) 
Correction: animal 
Context: ...n to a panicular genus or species of an anirmgl, cxccpl where the context 
4. Line 1, column 83 
Message: Possible spelling mistake found (deactivate) 
Context: ...nicular genus or species of an anirmgl, cxccpl where the context 
Potential problems found: 4 (time: 171ms) 
How you can improve LanguageTool 

데스크탑 소프트웨어. 설치 폴더와 내용을 내 소스 코드 및 API jar와 비교했지만 전자를 더 나은 솔루션으로 만드는 특별한 것을 찾을 수 없었습니다.

또한 맞춤법이 틀린 단어를 제안 목록의 첫 번째 요소로 바꾸고 싶습니다.

모든 종류의 도움을 받으실 수 있습니다.

답변

1

오래된 랑게 거 툴러 병을 사용하고있었습니다. 이것을 사용하십시오 - 또한

<dependency> 
<groupId>org.languagetool</groupId> 
<artifactId>language-en</artifactId> 
<version>3.5</version> 
</dependency> 

는 주문 보정 (match.getToPos()로) (match.getFromPos)에서 맞춤법이 틀린 단어를 선택하고 제안 목록에서 가장 설득력있는 단어로 대체하여 수행 할 수 있습니다 (그 프로그래머가 그 단어를 고를 때까지).

도움이 될 수 있기를 바랍니다.

+0

'3.5'은 현재 최신 버전이며, 3 개월 후에도 구형입니다. http://wiki.languagetool.org/java-api에있는 버전을 사용하십시오. 우리는 해당 페이지를 계속 업데이트합니다. (공개 : 저는 LanguageTool의 관리자입니다) –

+0

고맙다 Daniel .. – Rana