@@ -67,6 +67,7 @@ export interface Pluralizable {  
		
	
		
			
			interface WordOptions {  
		
	
		
			
			    plural: boolean;  
		
	
		
			
			    capital: boolean;  
		
	
		
			
			    allCaps: boolean;  
		
	
		
			
			    proper: boolean;  
		
	
		
			
			    kind: NounKind;  
		
	
		
			
			    vowel: VowelSound;  
		
	
	
		
			
				
				
				
				
					 
			
			@@ -74,6 +75,7 @@ interface WordOptions {  
		
	
		
			
			}  
		
	
		
			
			 
		
	
		
			
			const emptyConfig: WordOptions = {  
		
	
		
			
			  allCaps: false,  
		
	
		
			
			  capital: false,  
		
	
		
			
			  count: false,  
		
	
		
			
			  kind: NounKind.Specific,  
		
	
	
		
			
				
				
					 
			
			@@ -117,6 +119,12 @@ export abstract class Word {  
		
	
		
			
			  // These functions are pure; they don't mutate the original object.  
		
	
		
			
			  // This is necessary to avoid causing chaos.  
		
	
		
			
			 
		
	
		
			
			  get allCaps (): this {  
		
	
		
			
			    const opts: WordOptions = Object.assign({}, this.opt)  
		
	
		
			
			    opts.allCaps = true  
		
	
		
			
			    return this.configure(opts) as this  
		
	
		
			
			  }  
		
	
		
			
			 
		
	
		
			
			  get capital (): this {  
		
	
		
			
			    const opts: WordOptions = Object.assign({}, this.opt)  
		
	
		
			
			    opts.capital = true  
		
	
	
		
			
				
				
					 
			
			@@ -167,15 +175,14 @@ export abstract class Word {  
		
	
		
			
			}  
		
	
		
			
			 
		
	
		
			
			export class RandomWord extends Word {  
		
	
		
			
			  private last: number  
		
	
		
			
			 
		
	
		
			
			  constructor (public choices: Array<Word>, opt: WordOptions = emptyConfig) {  
		
	
		
			
			  private history: { last: number }  
		
	
		
			
			  constructor (public choices: Array<Word>, opt: WordOptions = emptyConfig, history: { last: number } = { last: -1 }) {  
		
	
		
			
			    super(opt)  
		
	
		
			
			    this.last = -1   
		
	
		
			
			    this.history = history   
		
	
		
			
			  }  
		
	
		
			
			 
		
	
		
			
			  configure (opts: WordOptions): Word {  
		
	
		
			
			    return new RandomWord(this.choices, opts)  
		
	
		
			
			    return new RandomWord(this.choices, opts, this.history )  
		
	
		
			
			  }  
		
	
		
			
			 
		
	
		
			
			  toString (): string {  
		
	
	
		
			
				
				
				
				
					 
			
			@@ -183,9 +190,9 @@ export class RandomWord extends Word {  
		
	
		
			
			 
		
	
		
			
			    do {  
		
	
		
			
			      choice = Math.floor(Math.random() * this.choices.length)  
		
	
		
			
			    } while (choice === this.last)  
		
	
		
			
			    } while (choice === this.history. last)  
		
	
		
			
			 
		
	
		
			
			    this.last = choice  
		
	
		
			
			    this.history. last = choice  
		
	
		
			
			    return this.choices[choice].configure(this.opt).toString()  
		
	
		
			
			  }  
		
	
		
			
			}  
		
	
	
		
			
				
				
					 
			
			@@ -234,7 +241,9 @@ export class Noun extends Word {  
		
	
		
			
			      }  
		
	
		
			
			    }  
		
	
		
			
			 
		
	
		
			
			    if (this.options.capital) {  
		
	
		
			
			    if (this.options.allCaps) {  
		
	
		
			
			      result = result.toUpperCase()  
		
	
		
			
			    } else if (this.options.capital) {  
		
	
		
			
			      result = result.slice(0, 1).toUpperCase() + result.slice(1)  
		
	
		
			
			    }  
		
	
		
			
			 
		
	
	
		
			
				
				
				
				
					 
			
			@@ -243,14 +252,14 @@ export class Noun extends Word {  
		
	
		
			
			}  
		
	
		
			
			 
		
	
		
			
			export class ImproperNoun extends Noun {  
		
	
		
			
			  constructor (singularNoun: string, pluralNoun: string) {  
		
	
		
			
			    super(singularNoun, pluralNoun, { plural: false, capital: false, proper: false, kind: NounKind.Specific, vowel: VowelSound.Default, count: true })  
		
	
		
			
			  constructor (singularNoun: string, pluralNoun: string = singularNoun ) {  
		
	
		
			
			    super(singularNoun, pluralNoun, { plural: false, allCaps: false,  capital: false, proper: false, kind: NounKind.Specific, vowel: VowelSound.Default, count: true })  
		
	
		
			
			  }  
		
	
		
			
			}  
		
	
		
			
			 
		
	
		
			
			export class ProperNoun extends Noun {  
		
	
		
			
			  constructor (singularNoun: string) {  
		
	
		
			
			    super(singularNoun, null, { plural: false, capital: false, proper: true, kind: NounKind.Specific, vowel: VowelSound.Default, count: true })  
		
	
		
			
			    super(singularNoun, null, { plural: false, allCaps: false,  capital: false, proper: true, kind: NounKind.Specific, vowel: VowelSound.Default, count: true })  
		
	
		
			
			  }  
		
	
		
			
			}