-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TextFeatureMapper, hardcoded for Duga's Programmer-comments features
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/net/zomis/machlearn/text/TextFeatureMapper.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,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(); | ||
} | ||
|
||
} |