R的语言解析器

时间:2017-06-26 08:40:10

标签: r parsing nlp

R中是否有解析器处理自然语言字符串并将其转换为R指令?类似于LEX和BISON for C ++。例如,它将转换此字符串:

<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 124 82">
  <defs>
    <style>
      .cls-1 {
        fill: none;
        stroke: #000;
        stroke-miterlimit: 10;
        stroke-width: 2px;
      }
    </style>
  </defs>
  <title>Untitled-5</title>
  <line class="cls-1" x1="12" y1="70" x2="44" y2="12">
    <animate attributeName="y1" from="70" to="35" dur="2s" fill="freeze"/>
    <animate attributeName="x2" from="44" to="59" dur="2s" fill="freeze"/>
    <animate attributeName="y2" from="12" to="56" dur="2s" fill="freeze"/>
  </line>
  <line class="cls-1" x1="44" y1="12" x2="112" y2="45">
    <animate attributeName="x1" from="44" to="59" dur="2s" fill="freeze"/>
    <animate attributeName="y1" from="12" to="56" dur="2s" fill="freeze"/>
    <animate attributeName="x2" from="112" to="100" dur="2s" fill="freeze"/>
    <animate attributeName="y2" from="45" to="12" dur="2s" fill="freeze"/>
  </line>
  <circle cx="12" cy="70" r="11" fill="white" stroke="black" stroke-width="2">
    <animate attributeName="cy" from="70" to="35" dur="2s" fill="freeze"/>
  </circle>
  <circle cx="44" cy="12" r="11" fill="white" stroke="black" stroke-width="2">
    <animate attributeName="cx" from="44" to="59" dur="2s" fill="freeze"/>
    <animate attributeName="cy" from="12" to="56" dur="2s" fill="freeze"/>
  </circle>
  <circle cx="112" cy="45" r="11" fill="white" stroke="black" stroke-width="2">
    <animate attributeName="cx" from="112" to="100" dur="2s" fill="freeze"/>
    <animate attributeName="cy" from="45" to="12" dur="2s" fill="freeze"/>
  </circle>
</svg>

Dataset: Cars - Column: Speed: 15 - Range: [20-40]

我所看到的仅适用于在C ++中集成R表达式,这就是我要问的原因。

1 个答案:

答案 0 :(得分:0)

这可以使用函数evaluate()和parse()来完成。 parse()将字符串转换为表达式。 evaluate()可以处理表达式:

txt1.Style = Seq.Resources["style"] as Style;

编辑:如果要自动创建表达式,则必须编写自己的函数。 paste()或cat()对于从多个输入创建文本字符串很有用。