You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by jeremie70 <gi...@git.apache.org> on 2016/02/26 12:03:20 UTC

[GitHub] nutch pull request: Add the boilerpipe parsing adapted from NUTCH-...

GitHub user jeremie70 opened a pull request:

    https://github.com/apache/nutch/pull/92

    Add the boilerpipe parsing adapted from NUTCH-961

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jeremie70/nutch my-branch

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nutch/pull/92.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #92
    
----
commit f185bc4461c57a1a85578de0ecf0884c7026c3a6
Author: Jérémie Bourseau <je...@xilopix.com>
Date:   2016-02-26T10:37:28Z

    improve parser with boilerpipe

commit 93ea2e51f444447be41ec93b2c0b0b61c117eeb3
Author: Jérémie Bourseau <je...@xilopix.com>
Date:   2016-02-26T10:37:28Z

    NUTCH-961 improve parser with boilerpipe

commit be91764fdf59d4f6930fc3211a84a252e5452674
Author: Jérémie Bourseau <je...@xilopix.com>
Date:   2016-02-26T11:00:36Z

    Merge branch 'my-branch' of https://github.com/jeremie70/nutch into my-branch

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request: Add the boilerpipe parsing adapted from NUTCH-...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nutch/pull/92


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request: Add the boilerpipe parsing adapted from NUTCH-...

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/nutch/pull/92#discussion_r54332193
  
    --- Diff: src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/BoilerpipeExtractorRepository.java ---
    @@ -0,0 +1,62 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nutch.parse.tika;
    +
    +import java.lang.ClassLoader;
    +import java.lang.InstantiationException;
    +import java.util.WeakHashMap;
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.tika.parser.html.BoilerpipeContentHandler;
    +import de.l3s.boilerpipe.BoilerpipeExtractor;
    +import de.l3s.boilerpipe.extractors.*;
    +
    +class BoilerpipeExtractorRepository {
    +
    +    public static final Log LOG = LogFactory.getLog(BoilerpipeExtractorRepository.class);
    +    public static final WeakHashMap<String, BoilerpipeExtractor> extractorRepository = new WeakHashMap<String, BoilerpipeExtractor>();
    + 
    +    /**
    +     * Returns an instance of the specified extractor
    +     */
    +    public static BoilerpipeExtractor getExtractor(String boilerpipeExtractorName) {
    +      // Check if there's no instance of this extractor
    +      if (!extractorRepository.containsKey(boilerpipeExtractorName)) {
    +        // FQCN
    +        boilerpipeExtractorName = "de.l3s.boilerpipe.extractors." + boilerpipeExtractorName;
    +
    +        // Attempt to load the class
    +        try {
    +          ClassLoader loader = BoilerpipeExtractor.class.getClassLoader();
    +          Class extractorClass = loader.loadClass(boilerpipeExtractorName);
    +
    +          // Add an instance to the repository
    +          extractorRepository.put(boilerpipeExtractorName, (BoilerpipeExtractor)extractorClass.newInstance());
    +
    +        } catch (ClassNotFoundException e) {
    +          LOG.error("BoilerpipeExtractor " + boilerpipeExtractorName + " not found!");
    --- End diff --
    
    In slf4j we can better structure the catch
    http://www.slf4j.org/faq.html#logging_performance
    e.g.
    ```
    logger.debug("The entry is {}.", entry);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request: Add the boilerpipe parsing adapted from NUTCH-...

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/nutch/pull/92#discussion_r54332145
  
    --- Diff: conf/nutch-default.xml ---
    @@ -876,6 +876,19 @@
       </description>
     </property>
     
    +<!-- tika properties -->
    +
    +<property>
    +  <name>tika.boilerpipe</name>
    +  <value>false</value>
    --- End diff --
    
    Can you provide descriptions of these properties please?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request: Add the boilerpipe parsing adapted from NUTCH-...

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/nutch/pull/92#discussion_r54332201
  
    --- Diff: src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/TikaParser.java ---
    @@ -109,7 +114,18 @@ public Parse getParse(String url, WebPage page) {
         HTMLDocumentImpl doc = new HTMLDocumentImpl();
         doc.setErrorChecking(false);
         DocumentFragment root = doc.createDocumentFragment();
    -    DOMBuilder domhandler = new DOMBuilder(doc, root);
    +   // DOMBuilder domhandler = new DOMBuilder(doc, root);
    +    ContentHandler domHandler;
    +    // Check whether to use Tika's BoilerplateContentHandler
    +    if (useBoilerpipe) {
    +        LOG.debug("Using Tikas's Boilerpipe with Extractor: " + boilerpipeExtractorName);
    --- End diff --
    
    Can also use more efficient slf4j convention
    logger.debug("The entry is {}.", entry);


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nutch pull request: Add the boilerpipe parsing adapted from NUTCH-...

Posted by lewismc <gi...@git.apache.org>.
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/nutch/pull/92#discussion_r54332155
  
    --- Diff: src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/BoilerpipeExtractorRepository.java ---
    @@ -0,0 +1,62 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nutch.parse.tika;
    +
    +import java.lang.ClassLoader;
    +import java.lang.InstantiationException;
    +import java.util.WeakHashMap;
    +import org.apache.commons.logging.Log;
    --- End diff --
    
    Nutch currently uses Slf4j
    
    org.slf4j.Logger
    org.slf4j.LoggerFactory
    
    I think!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---