Relevance query to check for size of line in a file

Hi,

I’d like a relevance query that makes sure the line containing string A in file A is the exact same in file B irrespective of its position.

For example, file A has first line as “I love apples” and second line as “I love oranges”. File B has first line as “I love oranges” and second line as “I love apples”. This shouldn’t matter but the fixlet should fail if file B has first line as “I love bananas” and second line as “I love apples”. “I love oranges” seems to have been modified.

I have a sample query but it’s not exactly what I want-

(line whose (it contains “apples”) of file A of it equals line whose (it contains “apples”) of file B of it) OR (line whose (it contains “oranges”) of file A of it equals line whose (it contains “oranges”) of file B of it)

How can I incorporate “size of” or “sha1 of”/“sha256 of” file to be the same in this query?

Any help will be appreciated!

Thank you,
Jennifer

Hi Jennifer. I’m not sure you need to use size of or checksums for this query. I think sets should work, like so:

(set of lines of file "C:\Temp\file1.txt" contains it and set of lines of file "C:\Temp\file2.txt" contains it) of set of ("I love apples"; "I love oranges")

Keep in mind this is case sensitive, not sure if that matters for you.

Here are some examples to show the file contents and some tests:

q: elements of set of lines of file "C:\Temp\file1.txt"
A: 3427894572
A: I love apples
A: I love bananas
A: I love oranges
A: junk
T: 1.863 ms

q: elements of set of lines of file "C:\Temp\file2.txt"
A: 123456789
A: I love bananas
A: I love candy
A: I love oranges
A: more junk
T: 1.538 ms

q: set of lines of file "C:\Temp\file1.txt" contains set of ("I love apples"; "I love oranges")
A: True
T: 1.222 ms

q: set of lines of file "C:\Temp\file2.txt" contains set of ("I love apples"; "I love oranges")
A: False
T: 0.852 ms

q: (set of lines of file "C:\Temp\file1.txt" contains it and set of lines of file "C:\Temp\file2.txt" contains it) of set of ("I love apples"; "I love oranges")
A: False
T: 0.537 ms
5 Likes

Hi Sean,

Using sets worked! Thank you so much! Had to change the query a bit to fit our needs :).

Thanks again,
Jennifer

2 Likes