forked from openhab/org.openhab.ui.habot
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yannick Schaus <[email protected]>
- Loading branch information
Showing
3 changed files
with
135 additions
and
61 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
41 changes: 41 additions & 0 deletions
41
src/main/java/org/openhab/ui/habot/nlp/internal/LowerCasePlainTextByLineStream.java
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.openhab.ui.habot.nlp.internal; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
import opennlp.tools.util.ObjectStream; | ||
|
||
public class LowerCasePlainTextByLineStream implements ObjectStream<String> { | ||
|
||
BufferedReader in; | ||
InputStream inputStream; | ||
final String encoding = "UTF-8"; | ||
|
||
public LowerCasePlainTextByLineStream(InputStream inputStream) throws IOException { | ||
this.inputStream = inputStream; | ||
reset(); | ||
} | ||
|
||
@Override | ||
public String read() throws IOException { | ||
String line = in.readLine(); | ||
if (line == null) { | ||
return null; | ||
} | ||
return line.toLowerCase().replace("<start:", "<START:").replace("<end>", "<END>"); | ||
} | ||
|
||
@Override | ||
public void reset() throws IOException { | ||
in = new BufferedReader(new InputStreamReader(inputStream, encoding)); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
if (in != null) { | ||
in.close(); | ||
} | ||
} | ||
} |
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