コード例 #1
0
 @Test
 public void shouldInsertVowel_A_WithHarmony() {
   final SuffixFormSequence.SuffixFormSequenceRuleType RULE_TYPE =
       SuffixFormSequence.SuffixFormSequenceRuleType.INSERT_VOWEL_A_WITH_HARMONY;
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.of();
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('a'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelBack);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('a'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelFrontal);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('e'));
   }
 }
コード例 #2
0
 @Test
 public void shouldInsertOptionalConsonant() {
   final SuffixFormSequence.SuffixFormSequenceRuleType RULE_TYPE =
       SuffixFormSequence.SuffixFormSequenceRuleType.INSERT_OPTIONAL_CONSONANT;
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub('k', RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.of();
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub('l', RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastLetterConsonant);
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub('m', RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastLetterVowel);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('m'));
   }
 }
コード例 #3
0
 @Test
 public void shouldApplySimpleRules() {
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(
             'm', SuffixFormSequence.SuffixFormSequenceRuleType.INSERT_NONVOWEL_LETTER);
     ImmutableSet<PhoneticAttribute> phoneticAttributes = mock(ImmutableSet.class);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('m'));
     verifyZeroInteractions(phoneticAttributes);
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(
             'a', SuffixFormSequence.SuffixFormSequenceRuleType.INSERT_VOWEL_WITHOUT_HARMONY);
     ImmutableSet<PhoneticAttribute> phoneticAttributes = mock(ImmutableSet.class);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('a'));
     verifyZeroInteractions(phoneticAttributes);
   }
 }
コード例 #4
0
 @Test
 public void shouldInsertVowel_I_WithHarmony_ButNoRounding() {
   final SuffixFormSequence.SuffixFormSequenceRuleType RULE_TYPE =
       SuffixFormSequence.SuffixFormSequenceRuleType.INSERT_VOWEL_I_WITH_HARMONY_AND_NO_ROUNDING;
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.of();
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('ı'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelBack);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('ı'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelFrontal);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('i'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('ı'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelBack, PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('ı'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelFrontal, PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('i'));
   }
 }
コード例 #5
0
 @Test
 public void shouldInsertOptionalVowel_I_WithHarmony() {
   final SuffixFormSequence.SuffixFormSequenceRuleType RULE_TYPE =
       SuffixFormSequence.SuffixFormSequenceRuleType.INSERT_OPTIONAL_VOWEL_I_WITH_HARMONY;
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes = ImmutableSet.of();
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelBack);
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelFrontal);
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelBack, PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastVowelFrontal, PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), nullValue());
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastLetterConsonant);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('ı'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(PhoneticAttribute.LastLetterConsonant, PhoneticAttribute.LastVowelBack);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('ı'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(
             PhoneticAttribute.LastLetterConsonant, PhoneticAttribute.LastVowelFrontal);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('i'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(
             PhoneticAttribute.LastLetterConsonant, PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('u'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(
             PhoneticAttribute.LastLetterConsonant,
             PhoneticAttribute.LastVowelBack,
             PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('u'));
   }
   {
     final SuffixFormSequence.SuffixFormSequenceRule rule =
         new SuffixFormSequenceRuleStub(RULE_TYPE);
     ImmutableSet<PhoneticAttribute> phoneticAttributes =
         ImmutableSet.of(
             PhoneticAttribute.LastLetterConsonant,
             PhoneticAttribute.LastVowelFrontal,
             PhoneticAttribute.LastVowelRounded);
     assertThat(applier.apply(rule, phoneticAttributes), equalTo('ü'));
   }
 }