Package cz.zcu.fav.liks.ml.featuresel.data

Examples of cz.zcu.fav.liks.ml.featuresel.data.Review


  protected HashMap<String, Integer> featureMap = new HashMap<String, Integer>();

  @Override
  public void extractFeature(InstanceList<Review> paramInstanceList,
      FeatureVectorGenerator paramFeatureVectorGenerator) {
    Review review = paramInstanceList.get(0);
    List<String> tokens = extractTokens(review);

    for (String word : tokens) {
      Integer index = featureMap.get(word);
      if (index != null && index < featureMap.size()) {
View Full Code Here


public class StatementCountFeature implements Feature<Review> {
  private static final long serialVersionUID = 1L;

  @Override
  public void extractFeature(InstanceList<Review> instanceList, FeatureVectorGenerator generator) {
    Review review = instanceList.get(0);
    List<Statement> statements = review.getStatements();
    int pos = 0, neg = 0;
    for (Statement s : statements) {
      if (s.isPositive()) {
        pos++;
      } else {
View Full Code Here

  public void train(TrainingInstanceList<Review> instances) {
    instances.reset();
    featureMap.clear();
    counts.clear();
    while (instances.hasNext()) {
      Review review = instances.next();
      int label = instances.getLabel(0);
      for (String word : extractReviewAndStatements(review, label)) {
        Integer count = (Integer) counts.get(word);
        if (count == null)
          counts.put(word, Integer.valueOf(1));
View Full Code Here

  private static final String ENCODING = "windows-1250";
  private List<Review> reviews;

  public CsvConn(String uri) {
    reviews = new ArrayList<Review>();
    Review last = null;
    try {
      BufferedReader bfr = new BufferedReader(new InputStreamReader(new FileInputStream(new File(uri)), ENCODING));
      while (bfr.ready()) {
        String[] line = bfr.readLine().split("\t");
        if (line[0].equals("R")) {
          last = parseReview(line);
          last.setStatements(new ArrayList<Statement>());
          reviews.add(last);
        } else {
          last.getStatements().add(parseStatement(line));
        }
      }

      bfr.close();
    } catch (UnsupportedEncodingException e) {
View Full Code Here

    }

  }

  private Review parseReview(String[] line) {
    Review r = new Review();
    r.setId(Integer.parseInt(line[1]));
    r.setText(line[2]);
    r.setUsefullVotes(Integer.parseInt(line[3]));
    r.setNotUsefullVotes(Integer.parseInt(line[4]));
    r.setRecomend(Boolean.parseBoolean(line[5]));
    r.setNotRecomend(Boolean.parseBoolean(line[6]));
    r.setRating(parseRating(line[7]));
    if (line.length > 8)
      r.setLemma(line[8]);
    return r;
  }
View Full Code Here

  public RandomReviewExtractor(List<Review> data, int trainingSize) {

    this.reviews.addAll(data);

    for (int i = 0; i < trainingSize; i++) {
      Review r = reviews.remove((int) (Math.random() * reviews.size()));
      trainingSet.add(r);

    }
    testSet.addAll(reviews);

 
View Full Code Here

    resultSet = preparedStatement.executeQuery();

    List<Review> reviews = new ArrayList<Review>();
    while (resultSet.next()) {
      Review review = new Review();
      review.setId(resultSet.getInt("id"));
      review.setNotRecomend(resultSet.getBoolean("notRecomend"));
      review.setRecomend(resultSet.getBoolean("recomend"));
      review.setNotUsefullVotes(resultSet.getInt("notUsefull"));
      review.setUsefullVotes(resultSet.getInt("usefull"));
      review.setRating(resultSet.getDouble("rating"));
      review.setText(resultSet.getString("text"));
      review.setStatements(getStatements(review.getId()));
      review.setLemma(resultSet.getString("lemma"));
      reviews.add(review);
    }

    preparedStatement.close();
    resultSet.close();
View Full Code Here

    int i = 0;
    ConfusionMatrix confusionMatrix = new ConfusionMatrix();
    // zaps�n� v�sledk�
    while (results.hasNext()) {
      int computedLabel = results.next().getBestLabel();
      Review r = testSet.get(i++);
      int realLabel = DataInfo.decideLabel(r);

      if (realLabel != -1) {
        confusionMatrix.increaseValue("" + realLabel, "" + computedLabel);
      }
View Full Code Here

TOP

Related Classes of cz.zcu.fav.liks.ml.featuresel.data.Review

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.