PML example: file line count

From Inference Web

Jump to: navigation, search

(draft example; see iw:PML Primer for an introduction to PML.)

by: Tim Lebo

The purpose of this PML example is to show how many sources of information can be used to answer a single question. Some of these sources provide conflicting information and the user must inspect the provenance to decide which to trust for an upcoming decision.

Contents

Scenario

Courtney wants to know how many lines are in a particular file letters.txt on her local system. The contents of letters.txt is:

a
b
c
d
e
f
g
h
i
k
l
m

The 'j' is intentionally missing in this example.

Encoding the question

:question1
  a pmlj:Question;
  pmlp:hasRawString "How many lines are in letters.txt?";
  pmlp:hasLanguage  <http://inference-web.org/registry/LG/English.owl#English>;
.

Approaches to getting an answer

Approach 1: User opens file and correctly counts each row. 12

Approach 2: User opens file and incorrectly counts each row. 11

Approach 3: User opens file, notices pattern, and infers number of rows based on 'm'. 13

Approach 4: User attaches letters.txt in an email to Doug and asks him to tell her how many lines are in the file. 12

"black box" Source; Courtney has no idea how Doug determined the line count

Approach 5: User attaches letters.txt in an email to Doug; Doug mentions his approach. 12

"gray box" Source; Doug mentions his approach.

Approach 6: Unix cat and awk. 12

bash-3.2$ cat letters.txt | awk '{print NR}'
1
2
3
4
5
6
7
8
9
10
11
12

Approach 7: Unix cat, awk, and tail. 12

bash-3.2$ cat letters.txt | awk '{print NR}' | tail -1
12

Approach 8: Unix wc misinterpreted. 25

Courtney does not know about (or forgot) the -l argument for wc, so just runs wc:

bash-3.2$ wc letters.txt
      12      12      25 letters.txt

In a hurry, she reads off the 25 (because it is next to the file name) and misinterprets that there are 25 letters in the file, which is still reasonable given that there are 26 letters in the alphabet.

Approach 9: Unix wc -l. 12

bash-3.2$ wc -l letters.txt
      12 letters.txt
Personal tools
Navigation