private SegmenterFactory buildSegmenterFactory() {
   FieldOptions options = context.field.fieldOptions();
   if (options.numberOfFragments() == 0) {
     return new WholeSourceSegmenterFactory();
   }
   if (options.fragmenter() == null || options.fragmenter().equals("scan")) {
     // TODO boundaryChars
     return new CharScanningSegmenterFactory(
         options.fragmentCharSize(), options.boundaryMaxScan());
   }
   if (options.fragmenter().equals("sentence")) {
     String localeString = (String) getOption("locale");
     Locale locale;
     if (localeString == null) {
       locale = Locale.US;
     } else {
       locale = Strings.parseLocaleString(localeString);
     }
     return new SentenceIteratorSegmenterFactory(locale, options.boundaryMaxScan());
   }
   if (options.fragmenter().equals("none")) {
     return new WholeSourceSegmenterFactory();
   }
   throw new IllegalArgumentException(
       "Unknown fragmenter:  '"
           + options.fragmenter()
           + "'.  Options are 'scan' or 'sentence'.");
 }