/* LanguageTool, a natural language style checker
 * Copyright (C) 2013 Marcin Milkowski (http://www.languagetool.org)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.tokenizers.en;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import org.languagetool.tokenizers.WordTokenizer;

/**
 * @author Marcin Milkowski
 * @since 2.5
 */
public class EnglishWordTokenizer extends WordTokenizer {

  private final String enTokenizing;

  public EnglishWordTokenizer() {
    enTokenizing = super.getTokenizingCharacters() + "–";  // n-dash
  }

  /**
   * Tokenizes text.
   * The English tokenizer differs from the standard one
   * in two respects:
   * <ol>
   * <li> it does not treat the hyphen as part of the
   * word if the hyphen is at the end of the word;</li>
   * <li> it includes n-dash and m-dash as tokenizing characters,
   * as these are used without a whitespace in English.
   * </ol>
   * @param text String of words to tokenize.
   */
  @Override
  public List<String> tokenize(final String text) {
    final List<String> l = new ArrayList<>();
    final StringTokenizer st = new StringTokenizer(text,
        enTokenizing, true);
    while (st.hasMoreElements()) {
      final String token = st.nextToken();
      if (token.length() > 1 && token.endsWith("-")) {
        l.add(token.substring(0, token.length() - 1));
        l.add("-");
      } else {
        l.add(token);
      }
    }
    return joinUrls(l);
  }
}

@@ -1552,20 +1552,11 @@
 sh a
-nd m-dash
+s
  a
-s
  tok
@@ -1572,17 +1572,16 @@
 haracter
-s
 ,%0A   * a
@@ -1586,17 +1586,13 @@
  as 
-these are
+it is
  use

update javadoc