Skip to content

Commit

Permalink
Add TextFeatureMapper, hardcoded for Duga's Programmer-comments features
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Feb 21, 2016
1 parent b4d2cb6 commit 69cd244
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/net/zomis/machlearn/text/TextFeatureMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.zomis.machlearn.text;

import java.util.stream.IntStream;

public class TextFeatureMapper {

private static final String[] CONTAINS = {
"better fit", "better suited", "better place",
"close", "off-topic", "design", "whiteboard", "this question", "this site",
"programmers.se", "help at", "place to ask", "migrate", "belong",
"instead", "the place for", "try programmers", "for programmers",
"on programmers", "at programmers", "to programmers" };

public double[] toFeatures(String str) {
return IntStream.range(0, CONTAINS.length)
.mapToDouble(i -> str.contains(CONTAINS[i]) ? 1 : 0)
.toArray();
}

}

0 comments on commit 69cd244

Please sign in to comment.