1 2 package net.sf.classifier4J.vector; 3 4 import java.io.Serializable; 5 6 7 public class TermVector implements Serializable { 8 private final String terms[]; 9 private final int values[]; 10 11 public TermVector(String[] terms, int[] values) { 12 this.terms = terms; 13 this.values = values; 14 } 15 16 public String[] getTerms() { 17 return (String[]) terms.clone(); 18 } 19 20 public int[] getValues() { 21 return (int[]) values.clone(); 22 } 23 24 public String toString() { 25 StringBuffer results = new StringBuffer("{"); 26 27 for (int i = 0; i < terms.length; i++) { 28 results.append("["); 29 results.append(terms[i]); 30 results.append(", "); 31 results.append(values[i]); 32 results.append("] "); 33 } 34 results.append("}"); 35 36 return results.toString(); 37 } 38 }