posts.addAll(sone.getPosts());
}
@SuppressWarnings("synthetic-access")
- Set<Hit<Post>> postHits = getHits(posts, phrases, new PostStringGenerator());
+ Set<Hit<Post>> postHits = getHits(Filters.filteredSet(posts, Post.FUTURE_POSTS_FILTER), phrases, new PostStringGenerator());
/* now filter. */
soneHits = Filters.filteredSet(soneHits, Hit.POSITIVE_FILTER);
int forbiddenHits = 0;
int requiredPhrases = 0;
for (Phrase phrase : phrases) {
+ String phraseString = phrase.getPhrase().toLowerCase();
if (phrase.getOptionality() == Phrase.Optionality.REQUIRED) {
++requiredPhrases;
}
- boolean matches = expression.toLowerCase().contains(phrase.getPhrase().toLowerCase());
- if (!matches) {
+ int matches = 0;
+ int index = 0;
+ while (index < expression.length()) {
+ int position = expression.toLowerCase().indexOf(phraseString, index);
+ if (position == -1) {
+ break;
+ }
+ index = position + phraseString.length();
+ ++matches;
+ }
+ if (matches == 0) {
continue;
}
if (phrase.getOptionality() == Phrase.Optionality.REQUIRED) {
- ++requiredHits;
+ requiredHits += matches;
}
if (phrase.getOptionality() == Phrase.Optionality.OPTIONAL) {
- ++optionalHits;
+ optionalHits += matches;
}
if (phrase.getOptionality() == Phrase.Optionality.FORBIDDEN) {
- ++forbiddenHits;
+ forbiddenHits += matches;
}
}
return requiredHits * 3 + optionalHits + (requiredHits - requiredPhrases) * 5 - (forbiddenHits * 2);
if (post.getRecipient() != null) {
postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(post.getRecipient()));
}
- for (Reply reply : webInterface.getCore().getReplies(post)) {
+ for (Reply reply : Filters.filteredList(webInterface.getCore().getReplies(post), Reply.FUTURE_REPLIES_FILTER)) {
postString.append(' ').append(SoneStringGenerator.NAME_GENERATOR.generateString(reply.getSone()));
postString.append(' ').append(reply.getText());
}