Added rhspin:normalizeWellBoreName with C# algorithm (issue #77)
Showing
1 changed file
with
250 additions
and
0 deletions
| ... | @@ -8,6 +8,7 @@ | ... | @@ -8,6 +8,7 @@ |
| 8 | # imports: http://www.reportinghub.no/ep/schema/1.0/report | 8 | # imports: http://www.reportinghub.no/ep/schema/1.0/report |
| 9 | # imports: http://www.reportinghub.no/np/schema/1.0/npd | 9 | # imports: http://www.reportinghub.no/np/schema/1.0/npd |
| 10 | 10 | ||
| 11 | +@prefix afn: <http://jena.hpl.hp.com/ARQ/function#> . | ||
| 11 | @prefix arg: <http://spinrdf.org/arg#> . | 12 | @prefix arg: <http://spinrdf.org/arg#> . |
| 12 | @prefix fn: <http://www.w3.org/2005/xpath-functions#> . | 13 | @prefix fn: <http://www.w3.org/2005/xpath-functions#> . |
| 13 | @prefix npdata: <http://www.reportinghub.no/np/data/> . | 14 | @prefix npdata: <http://www.reportinghub.no/np/data/> . |
| ... | @@ -217,6 +218,42 @@ rhspin:TableTemplates | ... | @@ -217,6 +218,42 @@ rhspin:TableTemplates |
| 217 | rdfs:subClassOf spin:SelectTemplates ; | 218 | rdfs:subClassOf spin:SelectTemplates ; |
| 218 | spin:abstract "true"^^xsd:boolean . | 219 | spin:abstract "true"^^xsd:boolean . |
| 219 | 220 | ||
| 221 | +rhspin:Test-normalizeWellBoreName-1 | ||
| 222 | + rdf:type spl:TestCase ; | ||
| 223 | + rdfs:label "Test-normalize well bore name-1"^^xsd:string ; | ||
| 224 | + spl:testExpression | ||
| 225 | + [ rdf:type rhspin:normalizeWellBoreName ; | ||
| 226 | + sp:arg1 "31/2-L12 Y1H" | ||
| 227 | + ] ; | ||
| 228 | + spl:testResult "31/2-L12 Y1H"^^xsd:string . | ||
| 229 | + | ||
| 230 | +rhspin:Test-normalizeWellBoreName-2 | ||
| 231 | + rdf:type spl:TestCase ; | ||
| 232 | + rdfs:label "Test-normalize well bore name-2"^^xsd:string ; | ||
| 233 | + spl:testExpression | ||
| 234 | + [ rdf:type rhspin:normalizeWellBoreName ; | ||
| 235 | + sp:arg1 "31/2-L12 T2" | ||
| 236 | + ] ; | ||
| 237 | + spl:testResult "31/2-L12"^^xsd:string . | ||
| 238 | + | ||
| 239 | +rhspin:Test-normalizeWellBoreName-3 | ||
| 240 | + rdf:type spl:TestCase ; | ||
| 241 | + rdfs:label "Test-normalize well bore name-3"^^xsd:string ; | ||
| 242 | + spl:testExpression | ||
| 243 | + [ rdf:type rhspin:normalizeWellBoreName ; | ||
| 244 | + sp:arg1 "31/2-L12 Q1" | ||
| 245 | + ] ; | ||
| 246 | + spl:testResult "31/2-L12"^^xsd:string . | ||
| 247 | + | ||
| 248 | +rhspin:Test-normalizeWellBoreName-4 | ||
| 249 | + rdf:type spl:TestCase ; | ||
| 250 | + rdfs:label "Test-normalize well bore name-4"^^xsd:string ; | ||
| 251 | + spl:testExpression | ||
| 252 | + [ rdf:type rhspin:normalizeWellBoreName ; | ||
| 253 | + sp:arg1 "31/2-'L12'," | ||
| 254 | + ] ; | ||
| 255 | + spl:testResult "31/2-L12"^^xsd:string . | ||
| 256 | + | ||
| 220 | rhspin:baaById | 257 | rhspin:baaById |
| 221 | rdf:type spin:Function ; | 258 | rdf:type spin:Function ; |
| 222 | rdfs:label "baa by id"^^xsd:string ; | 259 | rdfs:label "baa by id"^^xsd:string ; |
| ... | @@ -834,6 +871,219 @@ rhspin:normalizeString | ... | @@ -834,6 +871,219 @@ rhspin:normalizeString |
| 834 | ] ; | 871 | ] ; |
| 835 | spin:returnType xsd:string . | 872 | spin:returnType xsd:string . |
| 836 | 873 | ||
| 874 | +rhspin:normalizeWellBoreName | ||
| 875 | + rdf:type spin:Function ; | ||
| 876 | + rdfs:comment """Applies the following C# algorithm to a given well bore name: | ||
| 877 | + | ||
| 878 | + public static string removeTrackFromWellboreAlias(string wellboreAlias) { | ||
| 879 | + wellboreAlias = wellboreAlias.Replace(\"'\", \"\").TrimEnd(); | ||
| 880 | + if (wellboreAlias.Substring(wellboreAlias.Length - 1, 1) == \",\") | ||
| 881 | + wellboreAlias = wellboreAlias.Substring(0, wellboreAlias.Length - 1); | ||
| 882 | + | ||
| 883 | + if (wellboreAlias.IndexOf(\" \") > 0 && wellboreAlias.LastIndexOf(\"T\") > wellboreAlias.IndexOf(\" \")) | ||
| 884 | + { | ||
| 885 | + wellboreAlias = wellboreAlias.Remove(wellboreAlias.LastIndexOf(\"T\")); | ||
| 886 | + } | ||
| 887 | + | ||
| 888 | + if (wellboreAlias.IndexOf(\" \") > 0 && wellboreAlias.LastIndexOf(\"Q\") > wellboreAlias.IndexOf(\" \")) | ||
| 889 | + { | ||
| 890 | + wellboreAlias = wellboreAlias.Remove(wellboreAlias.LastIndexOf(\"Q\")); | ||
| 891 | + } | ||
| 892 | + return wellboreAlias.TrimEnd(); | ||
| 893 | + }"""^^xsd:string ; | ||
| 894 | + rdfs:label "normalize well bore name"^^xsd:string ; | ||
| 895 | + rdfs:subClassOf spin:Functions ; | ||
| 896 | + spin:body | ||
| 897 | + [ rdf:type sp:Select ; | ||
| 898 | + sp:resultVariables ([ rdf:type xsd:string ; | ||
| 899 | + sp:arg1 [ rdf:type spif:trim ; | ||
| 900 | + sp:arg1 [ sp:varName "result"^^xsd:string | ||
| 901 | + ] | ||
| 902 | + ] | ||
| 903 | + ]) ; | ||
| 904 | + sp:where ([ rdf:type sp:Bind ; | ||
| 905 | + sp:expression | ||
| 906 | + [ rdf:type spif:trim ; | ||
| 907 | + sp:arg1 [ rdf:type spif:replaceAll ; | ||
| 908 | + sp:arg1 spin:_arg1 ; | ||
| 909 | + sp:arg2 "'" ; | ||
| 910 | + sp:arg3 "" | ||
| 911 | + ] | ||
| 912 | + ] ; | ||
| 913 | + sp:variable | ||
| 914 | + [ sp:varName "a"^^xsd:string | ||
| 915 | + ] | ||
| 916 | + ] [ rdf:type sp:Bind ; | ||
| 917 | + sp:expression | ||
| 918 | + [ rdf:type sp:if ; | ||
| 919 | + sp:arg1 [ rdf:type sp:eq ; | ||
| 920 | + sp:arg1 [ rdf:type afn:substr ; | ||
| 921 | + sp:arg1 [ sp:varName "a"^^xsd:string | ||
| 922 | + ] ; | ||
| 923 | + sp:arg2 [ rdf:type sp:sub ; | ||
| 924 | + sp:arg1 [ rdf:type fn:string-length ; | ||
| 925 | + sp:arg1 [ sp:varName "a"^^xsd:string | ||
| 926 | + ] | ||
| 927 | + ] ; | ||
| 928 | + sp:arg2 1 | ||
| 929 | + ] ; | ||
| 930 | + sp:arg3 [ rdf:type fn:string-length ; | ||
| 931 | + sp:arg1 [ sp:varName "a"^^xsd:string | ||
| 932 | + ] | ||
| 933 | + ] | ||
| 934 | + ] ; | ||
| 935 | + sp:arg2 "," | ||
| 936 | + ] ; | ||
| 937 | + sp:arg2 [ rdf:type afn:substr ; | ||
| 938 | + sp:arg1 [ sp:varName "a"^^xsd:string | ||
| 939 | + ] ; | ||
| 940 | + sp:arg2 0 ; | ||
| 941 | + sp:arg3 [ rdf:type sp:sub ; | ||
| 942 | + sp:arg1 [ rdf:type fn:string-length ; | ||
| 943 | + sp:arg1 [ sp:varName "a"^^xsd:string | ||
| 944 | + ] | ||
| 945 | + ] ; | ||
| 946 | + sp:arg2 1 | ||
| 947 | + ] | ||
| 948 | + ] ; | ||
| 949 | + sp:arg3 [ sp:varName "a"^^xsd:string | ||
| 950 | + ] | ||
| 951 | + ] ; | ||
| 952 | + sp:variable | ||
| 953 | + [ sp:varName "b"^^xsd:string | ||
| 954 | + ] | ||
| 955 | + ] [ rdf:type sp:Bind ; | ||
| 956 | + sp:expression | ||
| 957 | + [ rdf:type spif:lastIndexOf ; | ||
| 958 | + sp:arg1 [ sp:varName "b"^^xsd:string | ||
| 959 | + ] ; | ||
| 960 | + sp:arg2 "T" | ||
| 961 | + ] ; | ||
| 962 | + sp:variable | ||
| 963 | + [ sp:varName "t"^^xsd:string | ||
| 964 | + ] | ||
| 965 | + ] [ rdf:type sp:Bind ; | ||
| 966 | + sp:expression | ||
| 967 | + [ rdf:type spif:lastIndexOf ; | ||
| 968 | + sp:arg1 [ sp:varName "b"^^xsd:string | ||
| 969 | + ] ; | ||
| 970 | + sp:arg2 " " | ||
| 971 | + ] ; | ||
| 972 | + sp:variable | ||
| 973 | + [ sp:varName "s1"^^xsd:string | ||
| 974 | + ] | ||
| 975 | + ] [ rdf:type sp:Bind ; | ||
| 976 | + sp:expression | ||
| 977 | + [ rdf:type sp:if ; | ||
| 978 | + sp:arg1 [ rdf:type sp:and ; | ||
| 979 | + sp:arg1 [ rdf:type sp:and ; | ||
| 980 | + sp:arg1 [ rdf:type sp:and ; | ||
| 981 | + sp:arg1 [ rdf:type sp:bound ; | ||
| 982 | + sp:arg1 [ sp:varName "s1"^^xsd:string | ||
| 983 | + ] | ||
| 984 | + ] ; | ||
| 985 | + sp:arg2 [ rdf:type sp:bound ; | ||
| 986 | + sp:arg1 [ sp:varName "t"^^xsd:string | ||
| 987 | + ] | ||
| 988 | + ] | ||
| 989 | + ] ; | ||
| 990 | + sp:arg2 [ rdf:type sp:gt ; | ||
| 991 | + sp:arg1 [ sp:varName "s1"^^xsd:string | ||
| 992 | + ] ; | ||
| 993 | + sp:arg2 0 | ||
| 994 | + ] | ||
| 995 | + ] ; | ||
| 996 | + sp:arg2 [ rdf:type sp:gt ; | ||
| 997 | + sp:arg1 [ sp:varName "t"^^xsd:string | ||
| 998 | + ] ; | ||
| 999 | + sp:arg2 [ sp:varName "s1"^^xsd:string | ||
| 1000 | + ] | ||
| 1001 | + ] | ||
| 1002 | + ] ; | ||
| 1003 | + sp:arg2 [ rdf:type afn:substr ; | ||
| 1004 | + sp:arg1 [ sp:varName "b"^^xsd:string | ||
| 1005 | + ] ; | ||
| 1006 | + sp:arg2 0 ; | ||
| 1007 | + sp:arg3 [ sp:varName "t"^^xsd:string | ||
| 1008 | + ] | ||
| 1009 | + ] ; | ||
| 1010 | + sp:arg3 [ sp:varName "b"^^xsd:string | ||
| 1011 | + ] | ||
| 1012 | + ] ; | ||
| 1013 | + sp:variable | ||
| 1014 | + [ sp:varName "c"^^xsd:string | ||
| 1015 | + ] | ||
| 1016 | + ] [ rdf:type sp:Bind ; | ||
| 1017 | + sp:expression | ||
| 1018 | + [ rdf:type spif:lastIndexOf ; | ||
| 1019 | + sp:arg1 [ sp:varName "c"^^xsd:string | ||
| 1020 | + ] ; | ||
| 1021 | + sp:arg2 "Q" | ||
| 1022 | + ] ; | ||
| 1023 | + sp:variable | ||
| 1024 | + [ sp:varName "q"^^xsd:string | ||
| 1025 | + ] | ||
| 1026 | + ] [ rdf:type sp:Bind ; | ||
| 1027 | + sp:expression | ||
| 1028 | + [ rdf:type spif:lastIndexOf ; | ||
| 1029 | + sp:arg1 [ sp:varName "c"^^xsd:string | ||
| 1030 | + ] ; | ||
| 1031 | + sp:arg2 " " | ||
| 1032 | + ] ; | ||
| 1033 | + sp:variable | ||
| 1034 | + [ sp:varName "s2"^^xsd:string | ||
| 1035 | + ] | ||
| 1036 | + ] [ rdf:type sp:Bind ; | ||
| 1037 | + sp:expression | ||
| 1038 | + [ rdf:type sp:if ; | ||
| 1039 | + sp:arg1 [ rdf:type sp:and ; | ||
| 1040 | + sp:arg1 [ rdf:type sp:and ; | ||
| 1041 | + sp:arg1 [ rdf:type sp:and ; | ||
| 1042 | + sp:arg1 [ rdf:type sp:bound ; | ||
| 1043 | + sp:arg1 [ sp:varName "s2"^^xsd:string | ||
| 1044 | + ] | ||
| 1045 | + ] ; | ||
| 1046 | + sp:arg2 [ rdf:type sp:bound ; | ||
| 1047 | + sp:arg1 [ sp:varName "q"^^xsd:string | ||
| 1048 | + ] | ||
| 1049 | + ] | ||
| 1050 | + ] ; | ||
| 1051 | + sp:arg2 [ rdf:type sp:gt ; | ||
| 1052 | + sp:arg1 [ sp:varName "s2"^^xsd:string | ||
| 1053 | + ] ; | ||
| 1054 | + sp:arg2 0 | ||
| 1055 | + ] | ||
| 1056 | + ] ; | ||
| 1057 | + sp:arg2 [ rdf:type sp:gt ; | ||
| 1058 | + sp:arg1 [ sp:varName "q"^^xsd:string | ||
| 1059 | + ] ; | ||
| 1060 | + sp:arg2 [ sp:varName "s2"^^xsd:string | ||
| 1061 | + ] | ||
| 1062 | + ] | ||
| 1063 | + ] ; | ||
| 1064 | + sp:arg2 [ rdf:type afn:substr ; | ||
| 1065 | + sp:arg1 [ sp:varName "c"^^xsd:string | ||
| 1066 | + ] ; | ||
| 1067 | + sp:arg2 0 ; | ||
| 1068 | + sp:arg3 [ sp:varName "q"^^xsd:string | ||
| 1069 | + ] | ||
| 1070 | + ] ; | ||
| 1071 | + sp:arg3 [ sp:varName "c"^^xsd:string | ||
| 1072 | + ] | ||
| 1073 | + ] ; | ||
| 1074 | + sp:variable | ||
| 1075 | + [ sp:varName "result"^^xsd:string | ||
| 1076 | + ] | ||
| 1077 | + ]) | ||
| 1078 | + ] ; | ||
| 1079 | + spin:constraint | ||
| 1080 | + [ rdf:type spl:Argument ; | ||
| 1081 | + rdfs:comment "The raw input name."^^xsd:string ; | ||
| 1082 | + spl:predicate sp:arg1 ; | ||
| 1083 | + spl:valueType xsd:string | ||
| 1084 | + ] ; | ||
| 1085 | + spin:returnType xsd:string . | ||
| 1086 | + | ||
| 837 | rhspin:npdId | 1087 | rhspin:npdId |
| 838 | rdf:type spin:Function ; | 1088 | rdf:type spin:Function ; |
| 839 | rdfs:comment "Gets the NPD id of a given NPD resource."^^xsd:string ; | 1089 | rdfs:comment "Gets the NPD id of a given NPD resource."^^xsd:string ; | ... | ... |
-
Please register or login to post a comment