Question

I am new to repidminer and for an academic project I am trying to extract text information from forum posts such as http://www.tripadvisor.com/ShowTopic-g29220-i86-k1487815-Alamo-Maui_Hawaii.html

I have tried a lot already and came up with the XPath query: //div[@class='postBody']/p[not(*)][text()]

Which works fine in google docs but not in rapidminer.

edit: Sorry, but your sugessted queries don't wprk in rapidminer. see my rapidminer process:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.015">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.3.015" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="web:get_webpage" compatibility="5.3.001" expanded="true" height="60" name="Get Page" width="90" x="45" y="75">
        <parameter key="url" value="http://www.tripadvisor.com/ShowTopic-g29220-i86-k1487815-Alamo-Maui_Hawaii.html"/>
        <parameter key="random_user_agent" value="true"/>
        <list key="query_parameters"/>
        <list key="request_properties"/>
      </operator>
      <operator activated="true" class="text:process_documents" compatibility="5.3.002" expanded="true" height="94" name="Process Documents" width="90" x="380" y="30">
        <process expanded="true">
          <operator activated="true" class="text:extract_information" compatibility="5.3.002" expanded="true" height="60" name="Extract Information" width="90" x="45" y="30">
            <parameter key="query_type" value="XPath"/>
            <list key="string_machting_queries"/>
            <list key="regular_expression_queries"/>
            <list key="regular_region_queries"/>
            <list key="xpath_queries">
              <parameter key="xpath1" value="//div[@class='postBody']"/>
              <parameter key="xpath2" value="//div[@class='postBody']/text()"/>
              <parameter key="xpath3" value="//div[@class='postBody']/p[not(*)][text()]"/>
            </list>
            <list key="namespaces"/>
            <list key="index_queries"/>
          </operator>
          <connect from_port="document" to_op="Extract Information" to_port="document"/>
          <connect from_op="Extract Information" from_port="document" to_port="document 1"/>
          <portSpacing port="source_document" spacing="0"/>
          <portSpacing port="sink_document 1" spacing="0"/>
          <portSpacing port="sink_document 2" spacing="0"/>
        </process>
      </operator>
      <connect from_op="Get Page" from_port="output" to_op="Process Documents" to_port="documents 1"/>
      <connect from_op="Process Documents" from_port="example set" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>

Any other ideas?

Was it helpful?

Solution

You have to put h: in front of the div and p node names.

So xpath3 would be

//h:div[@class='postBody']/h:p[not(*)][text()]

OTHER TIPS

If you want to get the whole post content try just:

 //div[@class='postBody']

or:

 //div[@class='postBody']/text()

Instead of:

 //div[@class='postBody']/p[not(*)][text()]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top