|
| 1 | +Anonymisation |
| 2 | +============= |
| 3 | + |
| 4 | +Mudlark can now be used to fully anonymise a Maintenance Work Order CSV file. In this section we will cover anonymising the text column, and anonymising other columns. |
| 5 | + |
| 6 | +Anonymising text |
| 7 | +---------------- |
| 8 | + |
| 9 | +To anonymise text, simply set the ``anonymise_text`` argument to True, either via command line or in a config file. |
| 10 | + |
| 11 | +When this is set to true, any terms that Mudlark deems to be "asset identifiers" will be anonymised and replaced with a unique asset identifier. For example, given the following data:: |
| 12 | + |
| 13 | + text |
| 14 | + ABC 124 is broken |
| 15 | + ABC 123 has a problem |
| 16 | + ABC-124 is broken |
| 17 | + pumps busted |
| 18 | + enGiNe was broken |
| 19 | + a leak was Formed |
| 20 | + |
| 21 | +The result will be:: |
| 22 | + |
| 23 | + text |
| 24 | + Asset1 is broken |
| 25 | + Asset2 has a problem |
| 26 | + Asset1 is broken |
| 27 | + pump bust |
| 28 | + engine is broken |
| 29 | + a leak is form |
| 30 | + |
| 31 | +Note how both ``ABC 124`` and ``ABC-124`` both become ``Asset1`` and ``ABC 123`` becomes ``Asset2``. |
| 32 | + |
| 33 | +Some further notes on how this works: |
| 34 | + |
| 35 | +* Currently a term is recognised as an asset identifier if it has one or more uppercase letter(s), followed by either nothing, a space, or a hyphen, then followed by one or more digit. |
| 36 | +* The order is randomised prior to generating the numbers for each asset identifier. |
| 37 | + |
| 38 | +Anonymising/processing other columns |
| 39 | +------------------------------------ |
| 40 | + |
| 41 | +Mudlark can also anonymise and/or process other columns. To do this, set ``column_config_path`` prior to running Mudlark (either via command line or in a config file). An example column config file might look like this:: |
| 42 | + |
| 43 | + columns: |
| 44 | + - name: floc |
| 45 | + handler: FLOC |
| 46 | + - name: mwo_id |
| 47 | + handler: RandomiseInteger |
| 48 | + - name: unique_floc_desc |
| 49 | + handler: ToUniqueString |
| 50 | + prefix: FLOC_Desc_ |
| 51 | + - name: other |
| 52 | + handler: None |
| 53 | + |
| 54 | +This file dictates which columns should be kept by Mudlark, and how it should handle each of them. There are currently four available "handlers": |
| 55 | + |
| 56 | +* ``None`` simply passes the column through to the output file without doing anything to it. |
| 57 | +* ``RandomiseInteger`` replaces each unique value of the column with a randomised integer (with 7 digits). |
| 58 | +* ``FLOC`` treats the column as a Functional Location. It splits it based on either a ``.`` or a ``-``, then converts each unique value of each level of the FLOC hierarchy into a number. For example, ``123-45-67`` might become ``1-1-1``, ``123-45-68`` might become ``1-1-2``, and so on. |
| 59 | +* ``ToUniqueString`` converts each unique value into an anonymised string, starting with the given ``prefix``. For example, ``Pump FLOC`` might become ``FLOC_Desc_1``, ``Belt FLOC`` might become ``FLOC_Desc_2``, and so on. |
| 60 | + |
| 61 | +Example |
| 62 | +^^^^^^^ |
| 63 | + |
| 64 | +Here is an example dataset:: |
| 65 | + |
| 66 | + text,cost,other,floc,mwo_id,unique_floc_desc |
| 67 | + ABC 124 is broken,123,test,123.45.67,123,FLOC 123 |
| 68 | + replace,43,xx,123.45.68,123,FLOC 124 |
| 69 | + X/X,540,test,123.45.69,123,FLOC 125 |
| 70 | + ABC 123 has a problem,3,test,123.45.67,123,FLOC 123 |
| 71 | + slurries,4.3,xx,123.45.67,123,FLOC 123 |
| 72 | + ABC-124 is broken,4.33,yrds,123.45.67,123,FLOC 123 |
| 73 | + pumps busted,43.43,tyrdtrd,111.45.67,123,FLOC 125 |
| 74 | + enGiNe was broken,4332.3,6t554,112.45.67,123,FLOC 126 |
| 75 | + a leak was Formed,333,545,113.45.67,123,FLOC 127 |
| 76 | + |
| 77 | +We are going to anonymise the text (as discussed in the first section), and will keep the ``floc``, ``mwo_id``, and ``unique_floc_desc`` columns. Here is our ``column-config.yml``:: |
| 78 | + |
| 79 | + columns: |
| 80 | + - name: floc |
| 81 | + handler: FLOC |
| 82 | + - name: mwo_id |
| 83 | + handler: RandomiseInteger |
| 84 | + - name: unique_floc_desc |
| 85 | + handler: ToUniqueString |
| 86 | + prefix: FLOC_Desc_ |
| 87 | + - name: other |
| 88 | + handler: None |
| 89 | + |
| 90 | +And our Mudlark config file:: |
| 91 | + |
| 92 | + input_path: my-file.csv |
| 93 | + output_path: my-file-out.csv |
| 94 | + text_column: text |
| 95 | + output_format: csv |
| 96 | + anonymise_text: true |
| 97 | + column_config: column-config.yml |
| 98 | + |
| 99 | +Once we run Mudlark, the output will be:: |
| 100 | + |
| 101 | + text,other,floc,mwo_id,unique_floc_desc |
| 102 | + Asset1 is broken,test,1_1_1,2462749,FLOC_Desc_1 |
| 103 | + replace,xx,1_1_2,7832383,FLOC_Desc_2 |
| 104 | + x/x,test,1_1_3,5472030,FLOC_Desc_3 |
| 105 | + Asset2 has a problem,test,1_1_1,2806910,FLOC_Desc_1 |
| 106 | + slurry,xx,1_1_1,1640112,FLOC_Desc_1 |
| 107 | + Asset1 is broken,yrds,1_1_1,7360650,FLOC_Desc_1 |
| 108 | + pump bust,tyrdtrd,2_1_1,9995977,FLOC_Desc_3 |
| 109 | + engine is broken,6t554,3_1_1,6573352,FLOC_Desc_4 |
| 110 | + a leak is form,545,4_1_1,6717645,FLOC_Desc_5 |
0 commit comments