SPT - Permutation Design
I. Introduction
This section describes the method to find all permutations with synonyms from pattern permutation results from the previous section.
II. Algorithm
- Go through all elements (synonym list) of the inList
- In the order from the last to the first (to looks nicer)
- Get the synonyms list of each element
- Duplicate the current permutation list to the number of synonym list
- Add all synonyms to the beginning of permutation list
III. Java Classes & Method
- Permutation.java: a Java class for finding all permutation
public Vector<String> GetPermutation(Vector<Vector<String>> inList)
IV. Examples
- Inputs:
Pattern 1
|
---|
word|synonyms
|
---|
who|
|
let|
|
dog|canine|k9|bull dog|
|
and|
|
cat|feline|
|
out|
|
Pattern 2
|
---|
word|synonyms
|
---|
who|
|
let|
|
dog and cat|pets|puppy and kitty|
|
out|
|
Algorithm Walk Through:
Pattern-Step | current element | permutation
|
---|
1-1 | out| |
|
1-2 | cat|feline| |
|
1-3 | and| | - and cat out
- and feline out
|
1-4 | dog|canine|k9|bull dog| | - dog and cat out
- dog and feline out
- canine and cat out
- canine and feline out
- k9 and cat out
- k9 and feline out
- bull dog and cat out
- bull dog and feline out
|
1-5 | let| | - let dog and cat out
- let dog and feline out
- let canine and cat out
- let canine and feline out
- let k9 and cat out
- let k9 and feline out
- let bull dog and cat out
- let bull dog and feline out
|
1-6 | who| | - who let dog and cat out (original input)
- who let dog and feline out
- who let canine and cat out
- who let canine and feline out
- who let k9 and cat out
- who let k9 and feline out
- who let bull dog and cat out
- who let bull dog and feline out
|
Pattern-Step | current element | permutation
|
---|
2-1 | out| |
|
2-2 | dog and cat|pets|puppy and kitty| | - dog and cat out
- pets out
- puppy and kitty out
|
2-3 | let| | - let dog and cat out
- let pets out
- let puppy and kitty out
|
2-4 | who| | - who let dog and cat out (original input)
- who let pets out
- who let puppy and kitty out
|
Outputs:
- who let dog and cat out
- who let dog and feline out
- who let canine and cat out
- who let canine and feline out
- who let k9 and cat out
- who let k9 and feline out
- who let bull dog and cat out
- who let bull dog and feline out
- who let pets out
- who let puppy and kitty out