public static ListMultimap<Category,UnaryRule> loadUnaryRules(final File file) throws IOException {
  final Multimap<Category,UnaryRule> result=HashMultimap.create();
  final Lexicon lexicon=new DefaultLexicon();
  for (  String line : Util.readFile(file)) {
    if (line.startsWith("#")) {
      continue;
    }
    line=line.trim();
    if (line.isEmpty()) {
      continue;
    }
    final String[] fields=line.split("\\s+");
    if (fields.length != 2 && fields.length != 3) {
      throw new Error("Expected 2 categories (and optional logical form) on line in UnaryRule file: " + line);
    }
    final String from=fields[0];
    final String to=fields[1];
    final Category cat=Category.make(Category.valueOf(to),Slash.FWD,Category.valueOf(from));
    Logic logic;
    if (fields.length == 3) {
      logic=LogicParser.fromString(fields[2],cat);
    }
 else {
      logic=lexicon.getEntry(null,"NULL",cat,Coindexation.fromString(to + "/" + from,-1));
    }
    result.put(Category.valueOf(from),new UnaryRule(result.size(),from,to,logic));
  }
  return ImmutableListMultimap.copyOf(result);
}

public static ListMultimap < Category , UnaryRule > loadUnaryRules ( final File file ) throws IOException { final Multimap < Category , UnaryRule > result = HashMultimap . create ( ) ; final Lexicon lexicon = new DefaultLexicon ( ) ; for ( String line : Util . readFile ( file ) ) { if ( line . startsWith ( "#" ) ) { continue ; } line = line . trim ( ) ; if ( line . isEmpty ( ) ) { continue ; } final String [ ] fields = line . split ( "\\s+" ) ; if ( fields . length != 2 && fields . length != 3 ) { throw new Error ( "Expected 2 categories (and optional logical form) on line in UnaryRule file: " + line ) ; } final String from = fields [ 0 ] ; final String to = fields [ 1 ] ; final Category cat = Category . make ( Category . valueOf ( to ) , Slash . FWD , Category . valueOf ( from ) ) ; Logic logic ; if ( fields . length == 3 ) { logic = LogicParser . fromString ( fields [ 2 ] , cat ) ; } else { logic = lexicon . getEntry ( null , "NULL" , cat , Coindexation . fromString ( to + "/" + from , - 1 ) ) ; } result . put ( Category . valueOf ( from ) , new UnaryRule ( result . size ( ) , from , to , logic ) ) ; } return ImmutableListMultimap . copyOf ( result ) ; }
loads file containing unary rules
