Skip to content

Commit

Permalink
Merge pull request #26 from metanorma/fix/isolate-term
Browse files Browse the repository at this point in the history
remove field of application and second line from IEV retrieved entry:…
  • Loading branch information
opoudjis authored Nov 22, 2021
2 parents 6e863bd + 743dd59 commit 62469c5
Show file tree
Hide file tree
Showing 4 changed files with 338 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/iev.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ module Iev
#
def self.get(code, lang)
url = "http://www.electropedia.org/iev/iev.nsf/"\
"display?openform&ievref=#{code}"
"display?openform&ievref=#{code}"
doc = Nokogiri::HTML OpenURI.open_uri(url), nil, "UTF-8"
xpath = "//table/tr/td/div/font[.=\"#{lang}\"]/../../"\
"following-sibling::td[2]"
doc.at(xpath)&.text&.strip
"following-sibling::td[2]"
a = doc&.at(xpath)&.children&.to_xml
a&.sub(%r{<br/>.*$}, "")
&.sub(%r{, &lt;.*$}, "")
&.gsub(%r{<[^>]*>}, "")&.strip
end
end
2 changes: 1 addition & 1 deletion lib/iev/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Iev
VERSION = "0.2.6".freeze
VERSION = "0.3.0".freeze
end
324 changes: 324 additions & 0 deletions spec/examples/103_08_14.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<TITLE>IEC 60050 - International Electrotechnical Vocabulary - Details for IEV number 103-08-14: "<i>p</i>-fractile"</TITLE>
<meta name="Description" content="Definition of <i>p</i>-fractile by Electropedia. Meaning of <i>p</i>-fractile. Translations of <i>p</i>-fractile. Equivalent terms for <i>p</i>-fractile." />
<meta name="Keywords" content="<i>p</i>-fractile, &lt;of a probability distribution&gt;, <i>p</i>-quantile, &lt;of a probability distribution&gt;,fractile d'ordre <i>p</i>, &lt;d'une loi de probabilité&gt; m, quantile d'ordre <i>p</i>, &lt;d'une loi de probabilité&gt; m,(لتوزيع احتمالى) p- كمية , (لتوزيع احتمالى) p- كسرية ,<i>p</i>-Quantil, &lt;einer Wahrscheinlichkeitsverteilung&gt; n, <i>p</i>-Fraktil, &lt;einer Wahrscheinlichkeitsverteilung&gt; n,fractil de orden <i>p</i> (de una ley de probabilidad),<i>p</i>-frattile (di una distribuzione di probabilità), quantile di ordine <i>p</i> (di una distribuzione di probabilità),<i>p</i>-分位点, &lt;確率分布の&gt;, <i>p</i>-分位点, &lt;確率分布の&gt;, <i>p</i>-フラクタイル, &lt;確率分布の&gt;, <i>p</i>-クォンタイル, &lt;確率分布の&gt;,kwantyl rzędu <i>p</i>, fraktyl rzędu <i>p</i>,fractil-<i>p</i> (de uma distribuição de probabilidade), quantil-<i>p</i> (de uma distribuição de probabilidade),<i>p</i>-fraktil (av en sannolikhetsfördelning),<i>p</i> 분위수, &lt;확률분포&gt;,<i>p</i>-квантил, &lt;расподеле вероватноће&gt; м јд,p-分位数, &lt;一个概率分布的&gt;, dictionary, definition, meaning, translation, term, terminology, IEC 60050, Electropedia, IEV 103-08-14,IEV, International, Electrotechnical, Vocabulary, VEI, Vocabulaire, Electrotechnique, Internationale, IEC, electric, electronic" />
<meta name="Copyright" content="IEC - International Electrotechnical Commission" />
<meta name="Language" content="English, French, Arabic, Chinese, Czech, Finnish, German, Italian, Japanese, Norwegian, Polish, Portuguese, Russian, Serbian, Slovenian, Spanish, Swedish" />
<SCRIPT language="JavaScript">

function printWindow() { bV = parseInt(navigator.appVersion); if (bV >= 4) window.print(); }

function popup(name) { msgWindow=open(name,'popup','history=yes,toolbar=no,scrollbars=yes,resizable=yes,width=700,height=750'); }

</SCRIPT>

<STYLE TYPE="text/css">
a:link {color: blue ; text-decoration: none}
a:visited { color: blue ; text-decoration: none }
a:active { color: blue ; text-decoration: none }
a:hover { color: blue ; text-decoration: none; background-color: #C0C0C0}
table {font-family: arial}
td { font-size: 11pt; font-family: Arial, Helvetica, sans-serif }
h6 {page-break-before: always;}
</STYLE>

<STYLE TYPE="text/css" media="print">
.hide { display: none }
</STYLE>
<!-- Google Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34400412-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- End Google Analytics -->
<meta name="Description" content="<i>p</i>-fractile, &lt;of a probability distribution&gt;, <i>p</i>-quantile, &lt;of a probability distribution&gt;,fractile d'ordre <i>p</i>, &lt;d'une loi de probabilité&gt; m, quantile d'ordre <i>p</i>, &lt;d'une loi de probabilité&gt; m,(لتوزيع احتمالى) p- كمية , (لتوزيع احتمالى) p- كسرية ,<i>p</i>-Quantil, &lt;einer Wahrscheinlichkeitsverteilung&gt; n, <i>p</i>-Fraktil, &lt;einer Wahrscheinlichkeitsverteilung&gt; n,fractil de orden <i>p</i> (de una ley de probabilidad),<i>p</i>-frattile (di una distribuzione di probabilità), quantile di ordine <i>p</i> (di una distribuzione di probabilità),<i>p</i>-分位点, &lt;確率分布の&gt;, <i>p</i>-分位点, &lt;確率分布の&gt;, <i>p</i>-フラクタイル, &lt;確率分布の&gt;, <i>p</i>-クォンタイル, &lt;確率分布の&gt;,kwantyl rzędu <i>p</i>, fraktyl rzędu <i>p</i>,fractil-<i>p</i> (de uma distribuição de probabilidade), quantil-<i>p</i> (de uma distribuição de probabilidade),<i>p</i>-fraktil (av en sannolikhetsfördelning),<i>p</i> 분위수, &lt;확률분포&gt;,<i>p</i>-квантил, &lt;расподеле вероватноће&gt; м јд,p-分位数, &lt;一个概率分布的&gt;" >
<STYLE TYPE="text/css">
@font-face { font-family: 'liberation_serifitalic';
src: url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_italic_macroman/LiberationSerif-Italic-webfont.eot');
src: url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_italic_macroman/LiberationSerif-Italic-webfont.eot?#iefix') format('embedded-opentype'),
url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_italic_macroman/LiberationSerif-Italic-webfont.woff') format('woff'),
url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_italic_macroman/LiberationSerif-Italic-webfont.ttf') format('truetype'),
url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_italic_macroman/LiberationSerif-Italic-webfont.svg#liberation_serifitalic') format('svg');
}

@font-face { font-family: 'liberation_serifregular';
src: url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_regular_macroman/LiberationSerif-Regular-webfont.eot');
src: url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_regular_macroman/LiberationSerif-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_regular_macroman/LiberationSerif-Regular-webfont.woff') format('woff'),
url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_regular_macroman/LiberationSerif-Regular-webfont.ttf') format('truetype'),
url('/font/Liberation-Serif-fontfacekit/web%20fonts/liberationserif_regular_macroman/LiberationSerif-Regular-webfont.svg#liberation_serifregular') format('svg');
font-weight: normal; font-style: normal;}
* {font-family: liberation_serifregular;}body {font-family: liberation_serifregular;}td {font-family: liberation_serifregular;}i {font-family: liberation_serifitalic;}#copy td { font-size:11px; }#copy a { font-size:11px; text-decoration: none;}#copy {border-top: 1px #c0c0c0 solid;}hr {height: 1px; color: #c0c0c0;}</STYLE><script type="text/javascript" src="/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script language="JavaScript" type="text/javascript">
<!--
document._domino_target = "_self";
function _doClick(v, o, t, h) {
var form = document._Display;
if (form.onsubmit) {
var retVal = form.onsubmit();
if (typeof retVal == "boolean" && retVal == false)
return false;
}
var target = document._domino_target;
if (o.href != null) {
if (o.target != null)
target = o.target;
} else {
if (t != null)
target = t;
}
form.target = target;
form.__Click.value = v;
if (h != null)
form.action += h;
form.submit();
return false;
}
// -->
</script>
</head>
<body text="#000000" bgcolor="#FFFFFF" leftmargin=10 topmargin=0>

<form method="post" action="/iev/iev.nsf/display?OpenForm&amp;Seq=1&amp;ievref=103-08-14" name="_Display">
<input type="hidden" name="__Click" value="0" /><style>
.Top {
margin: auto;
height: 109px;
padding: 0px;
font-family: Arial, Helvetica;
}
.logolink {
position: relative;
width: 260px;
height: 60px;
top: 20px;
left: 8px;
float: left;
font-family: Arial, Helvetica, sans-serif;
}
.logolink h1 {
color: #000;
font-size: 17px;
font-weight: bold;
letter-spacing: 2px;
float:left;
top:-60px;
margin:0;
margin-left:80px;
position:relative;
font-family: Arial, Helvetica, sans-serif;
}
.top {
outline: none;
margin: 0px;
padding: 0px;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
</style><div class="Top">
<div class="logolink"><a title="Back to homepage" href="http://www.iec.ch/">
<img title="www.iec.ch" alt=" www.iec.ch" src="/img/logo.jpg"></a>
<h1>International</h1>
<h1>Electrotechnical</h1>
<h1>Commission</h1>
</div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%" valign="middle"><img width="65" height="1" src="/icons/ecblank.gif" border="0" alt="" /><br />
</td><td width="1%"><img width="19" height="1" src="/icons/ecblank.gif" border="0" alt="" /><br />
</td><td width="46%" valign="middle"><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /><br />
</td><td width="1%"><img width="19" height="1" src="/icons/ecblank.gif" border="0" alt="" /><br />
</td><td width="54%"><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /><br />
</td></tr>
</table>
<div align="right"><font size="2" face="Arial"> </font><a href="&amp;login"></a></div>
<table style="width: 100%; margin-bottom: 10px;" cellpadding=0 width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td style="width: 144px;" width="15%"><img src="/iev/iev.nsf/30c867bbcbcee00dc1257e81003e697e/$Body/0.E5A?OpenElement&amp;FieldElemFormat=gif" width="144" height="20" /></td><td class="hide" style="border-top: 1px #c0c0c0 solid; width: 100% !important; " width="85%"><div align="right"><font size="2" face="Arial">Queries, comments, suggestions? Please </font><a href="mailto:[email protected]"><font size="2" face="Arial">contact us</font></a><font size="2" face="Arial">.</font></div></td></tr>
</table>
<br />

<input type="button" value=" Home " class="hide" style="font-size: 11px;" onclick="window.open('/iev/iev.nsf/6d6bdd8667c378f7c12581fa003d80e7?OpenForm', document._domino_target);" />
<input type="button" onclick="history.back()" value=" Back " class="hide" style="font-size: 11px;" />
<input type="button" onclick="printWindow()" value=" Print " class="hide" style="font-size: 11px;" /><style>
td.col1 {width:57px;}
td.col11 {width:55px;}
td.col2 {width:21px;}
td.col21 {width:19px;width:25px; text-align:left;}
td.col3 {width:567px;}
td.col4 {width:57px;}
table.table1 {width:710px;}
</style>
<font face=""><br>

<br />

<table class ="table1" cellpadding="1" cellspacing="0" border="0" cellpadding="0">
<tr valign="top">
<td class="col1"><b><font size="2" color="#800080" face="Arial">Area</font></b></td>
<td class="col2"><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td class="col3"><b><font size="2" face="Arial"></font></b><a href=index?openform&part=103>Mathematics - Functions</a> / Probability </td>
<td class="col4"><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><b><font size="2" color="#800080" face="Arial">IEV ref</font></b></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td><b><b>103-08-14</b></b></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
</tr>


<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">en</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td><b><i>p</i>-fractile</b>, &lt;of a probability distribution&gt;<br><b><i>p</i>-quantile</b>, &lt;of a probability distribution&gt;</td>
</tr>
<tr valign="top">
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> for a number <i>p</i> between 0 and 1, value of a random variable for which the distribution function equals <i>p</i> or jumps from a value less than or equal to <i>p</i> to a value greater than <i>p</i> </td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">fr</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> <b>fractile d'ordre <i>p</i></b>, &lt;d'une loi de probabilité&gt; m<br><b>quantile d'ordre <i>p</i></b>, &lt;d'une loi de probabilité&gt; m</td>
</tr>
<tr valign="top">
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> pour un nombre <i>p</i> compris entre 0 et 1, valeur d'une variable aléatoire pour laquelle la fonction de répartition prend une valeur <i>p</i> ou saute d'une valeur inférieure ou égale à <i>p</i> à une valeur supérieure à <i>p</i> </td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">ar</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td style="direction:rtl; text-align:left" widthx="567"> (لتوزيع احتمالى) p- كمية <br>(لتوزيع احتمالى) p- كسرية </td>
</tr>


<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">de</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> <i>p</i>-Quantil, &lt;einer Wahrscheinlichkeitsverteilung&gt; n<br><i>p</i>-Fraktil, &lt;einer Wahrscheinlichkeitsverteilung&gt; n</td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">es</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> fractil de orden <i>p</i> (de una ley de probabilidad)</td>
</tr>


<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">it</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> <i>p</i>-frattile (di una distribuzione di probabilità)<br>quantile di ordine <i>p</i> (di una distribuzione di probabilità)</td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080" face="Arial">ko</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> <i>p</i> 분위수, &lt;확률분포&gt;</td>
</tr>

<tr valign="top">
<td width="701" colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">ja</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td lang="ja-jp"> <i>p</i>-分位点, &lt;確率分布の&gt;<br><i>p</i>-分位点, &lt;確率分布の&gt;<br><i>p</i>-フラクタイル, &lt;確率分布の&gt;<br><i>p</i>-クォンタイル, &lt;確率分布の&gt;</td>
</tr>




<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080" face="Arial">pl</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> kwantyl rzędu <i>p</i><br>fraktyl rzędu <i>p</i></td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080" face="Arial">pt</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> fractil-<i>p</i> (de uma distribuição de probabilidade)<br>quantil-<i>p</i> (de uma distribuição de probabilidade)</td>
</tr>


<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">sr</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> <i>p</i>-квантил, &lt;расподеле вероватноће&gt; м јд</td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080">sv</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> <i>p</i>-fraktil (av en sannolikhetsfördelning)</td>
</tr>

<tr valign="top">
<td colspan="4"><hr></td>
</tr>
<tr valign="top">
<td><div align="center"><font color="#800080" face="Arial">zh</font></div></td>
<td><img width="1" height="1" src="/icons/ecblank.gif" border="0" alt="" /></td>
<td> p-分位数, &lt;一个概率分布的&gt;</td>
</tr>
</table>

</font><hr>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="25%"><a href="/iev/iev.nsf/display?openform&amp;ievref=103-08-14&amp;login"></a><font color="#800080">Publication date:</font> 2009-12 </td><td width="75%"><div align="right"><a href="http://www.iec.ch/about/copyright/copyright-db_entry.htm" target="_blank"><font color="#003399">Copyright</font></a> © <a href="http://www.iec.ch/about/co/office-e.htm" target="_blank"><font color="#003399">IEC</font></a> 2021. All Rights Reserved.</div></td></tr>
</table>
</form>
</body>
</html>
7 changes: 7 additions & 0 deletions spec/iev_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
expect(File.exist?("testcache2")).to be_truthy
end

# <td><b><i>p</i>-fractile</b>, &lt;of a probability distribution&gt;<br><b><i>p</i>-quantile</b>, &lt;of a probability distribution&gt;</td>
it "strips extraneous information from term" do
mock_open_uri("103-08-14")
term = @db.fetch "103-08-14", "en"
expect(term).to eq "p-fractile"
end

it "return empty string if code not found" do
mock_open_uri("111-11-11")
term = @db.fetch "111-11-11", "en"
Expand Down

0 comments on commit 62469c5

Please sign in to comment.