Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- public class Document {
- private final String label;
- private final List words;
- private String guid;
- public Document(File file, String label) throws IOException {
- this.label = label;
- BufferedReader reader = new BufferedReader(new FileReader(file));
- words = new ArrayList();
- String line = null;
- while ((line = reader.readLine()) != null) {
- for (String word : line.split("\\s+"))
- words.add(word.trim());
- }
- reader.close();
- }
- public void setGUID(String guid) {
- this.guid = guid;
- }
- public String getGUID(){
- return this.guid;
- }
- /**
- * Recall that this is used in SpamClassifier.lbj
- */
- public String getLabel() {
- return label;
- }
- /**
- * As is this.
- */
- public List getWords() {
- return Collections.unmodifiableList(words);
- }
- @Override
- public String toString() {
- return label + ", " + words;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement