Permalink
Browse files

add indices test for hashtags

  • Loading branch information...
1 parent 3fe208d commit 40aba3766ec9d65e649142944cfa64cf379d7cc4 @hjz hjz committed May 27, 2011
Showing with 19 additions and 8 deletions.
  1. +2 −2 src/com/twitter/Extractor.java
  2. +17 −6 tests/com/twitter/ExtractorTest.java
@@ -94,7 +94,7 @@ public Extractor() {
* @param text of the tweet from which to extract usernames
* @return List of usernames referenced (without the leading @ sign)
*/
- public List<Entity> extractMentionedScreennamesWithIndicies(String text) {
+ public List<Entity> extractMentionedScreennamesWithIndices(String text) {
if (text == null) {
return null;
}
@@ -160,7 +160,7 @@ public String extractReplyScreenname(String text) {
* @param text of the tweet from which to extract URLs
* @return List of URLs referenced.
*/
- public List<Entity> extractURLsWithIndicies(String text) {
+ public List<Entity> extractURLsWithIndices(String text) {
if (text == null) {
return null;
}
@@ -35,7 +35,7 @@ public void testReplyWithLeadingSpace() {
}
/**
- * Tests for the extractMentionedScreennames{WithIndicies} methods
+ * Tests for the extractMentionedScreennames{WithIndices} methods
*/
public static class MentionTest extends ExtractorTest {
public void testMentionAtTheBeginning() {
@@ -58,8 +58,8 @@ public void testMultipleMentions() {
assertList("Failed to extract multiple mentioned users", new String[]{"user1", "user2"}, extracted);
}
- public void testMentionWithIndicies() {
- List<Extractor.Entity> extracted = extractor.extractMentionedScreennamesWithIndicies(" @user1 mention @user2 here @user3 ");
+ public void testMentionWithIndices() {
+ List<Extractor.Entity> extracted = extractor.extractMentionedScreennamesWithIndices(" @user1 mention @user2 here @user3 ");
assertEquals(extracted.size(), 3);
assertEquals(extracted.get(0).start.intValue(), 1);
assertEquals(extracted.get(0).end.intValue(), 7);
@@ -93,14 +93,25 @@ public void testMultipleHashtags() {
List<String> extracted = extractor.extractHashtags("text #hashtag1 #hashtag2");
assertList("Failed to extract multiple hashtags", new String[]{"hashtag1", "hashtag2"}, extracted);
}
+
+ public void testHashtagWithIndices() {
+ List<Extractor.Entity> extracted = extractor.extractHashtagsWithIndices(" #user1 mention #user2 here #user3 ");
+ assertEquals(extracted.size(), 3);
+ assertEquals(extracted.get(0).start.intValue(), 1);
+ assertEquals(extracted.get(0).end.intValue(), 7);
+ assertEquals(extracted.get(1).start.intValue(), 16);
+ assertEquals(extracted.get(1).end.intValue(), 22);
+ assertEquals(extracted.get(2).start.intValue(), 28);
+ assertEquals(extracted.get(2).end.intValue(), 34);
+ }
}
/**
- * Tests for the extractURLsWithIndicies method
+ * Tests for the extractURLsWithIndices method
*/
public static class URLTest extends ExtractorTest {
- public void testUrlWithIndicies() {
- List<Extractor.Entity> extracted = extractor.extractURLsWithIndicies("http://t.co url https://www.twitter.com ");
+ public void testUrlWithIndices() {
+ List<Extractor.Entity> extracted = extractor.extractURLsWithIndices("http://t.co url https://www.twitter.com ");
assertEquals(extracted.get(0).start.intValue(), 0);
assertEquals(extracted.get(0).end.intValue(), 11);
assertEquals(extracted.get(1).start.intValue(), 16);

0 comments on commit 40aba37

Please sign in to comment.