SentenceFilteredGrammar(AbstractGrammar baseGrammar,Sentence sentence){
  super(OwnerMap.getOwner(baseGrammar.getOwner()),baseGrammar.joshuaConfiguration,baseGrammar.getSpanLimit());
  this.baseGrammar=baseGrammar;
  this.sentence=sentence;
  this.tokens=sentence.getWordIDs();
  int origCount=getNumRules(baseGrammar.getTrieRoot());
  long startTime=System.currentTimeMillis();
  this.filteredTrie=filter(baseGrammar.getTrieRoot());
  int filteredCount=getNumRules();
  float seconds=(System.currentTimeMillis() - startTime) / 1000.0f;
  LOG.debug("Sentence-level filtering of sentence {} ({} -> {} rules) in {} seconds",sentence.id(),origCount,filteredCount,seconds);
}

SentenceFilteredGrammar ( AbstractGrammar baseGrammar , Sentence sentence ) { super ( OwnerMap . getOwner ( baseGrammar . getOwner ( ) ) , baseGrammar . joshuaConfiguration , baseGrammar . getSpanLimit ( ) ) ; this . baseGrammar = baseGrammar ; this . sentence = sentence ; this . tokens = sentence . getWordIDs ( ) ; int origCount = getNumRules ( baseGrammar . getTrieRoot ( ) ) ; long startTime = System . currentTimeMillis ( ) ; this . filteredTrie = filter ( baseGrammar . getTrieRoot ( ) ) ; int filteredCount = getNumRules ( ) ; float seconds = ( System . currentTimeMillis ( ) - startTime ) / 1000.0f ; LOG . debug ( "Sentence-level filtering of sentence {} ({} -> {} rules) in {} seconds" , sentence . id ( ) , origCount , filteredCount , seconds ) ; }
construct a new sentence - filtered grammar . the main work is done in the enclosed trie ( obtained from the base grammar , which contains the complete grammar ) .
