Skip to content

Instantly share code, notes, and snippets.

@msoutopico
Created April 23, 2024 11:27
Show Gist options
  • Save msoutopico/3b67fd7490e59c24993e90daad5ae4a3 to your computer and use it in GitHub Desktop.
Save msoutopico/3b67fd7490e59c24993e90daad5ae4a3 to your computer and use it in GitHub Desktop.
check_subset.groovy
/* :name = Contains Subset :description =
*
* @author: Manuel Souto Pico
* @date: 2024-03-11
* @version: 0.0.1
*
*/
import org.omegat.util.StaticUtils
def projectSave = [
[key1: 'foo', key2: 'fóó'],
[key1: 'bar', key2: 'bàr'],
[key1: 'qux', key2: 'qüx']
]
// Define your sets (lists of maps)
def batchTM1 = [
[key1: 'foo', key2: 'fóó'],
[key1: 'bar', key2: 'bàr']
]
// Check if batchTM1 is a subset of projectSave
def isSubset1 = projectSave.containsAll(batchTM1)
// Output the result
console.println "batchTM1 is a subset of projectSave: ${isSubset1}"
// Define your sets (lists of maps)
def batchTM2 = [
[key1: 'foo', key2: 'fóó'],
[key1: 'bar', key2: 'bàààààr'],
]
// Check if batchTM is a subset of projectSave
def isSubset2 = projectSave.containsAll(batchTM2)
// Output the result
console.println "batchTM2 is a subset of projectSave: ${isSubset2}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment