[ 
https://issues.apache.org/jira/browse/OPENNLP-1531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17801478#comment-17801478
 ] 

Bruno P. Kinoshita commented on OPENNLP-1531:
---------------------------------------------

To generate the list of abbreviations from the Academia Brasileira de Letras:
{code:java}
 // https://www.academia.org.br/nossa-lingua/reducoes
var tokens = [...document.getElementsByTagName("p")].reduce((acc, p) => {
  const text = p.innerText
  if (text !== undefined && text !== null && text.trim() !== "") {
    const tokens = text.split(" ")
    if (tokens.length >= 2) {
      const possibleAbbreviation = tokens[0].trim().toLowerCase()
      if (possibleAbbreviation.includes('.') && 
!acc.includes(possibleAbbreviation)) {
        acc.push(possibleAbbreviation)
      }
    }
  }
  return acc
}, [])// Create OpenNLP abb_PT.xml file
var xml = [`<?xml version="1.0" encoding="UTF-8"?><!--
   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.
--><dictionary case_sensitive="false">`]
tokens.forEach(token => {
  xml.push(`  <entry>
    <token>${token}</token>
  </entry>`)
})
xml.push('</dictionary>')// Copy to clipboard
copy(xml.join('\n')){code}
Running that in Firefox will parse the HTML, create the XML body, and copy it 
to the system clipboard.

> Add Portuguese abbreviation dictionary
> --------------------------------------
>
>                 Key: OPENNLP-1531
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1531
>             Project: OpenNLP
>          Issue Type: Improvement
>    Affects Versions: 2.3.1
>            Reporter: Bruno P. Kinoshita
>            Priority: Minor
>
> Similar to the addition in OPENNLP-570 and OPENNLP-1526, an abbreviation 
> dictionary for Italian sentence detection and tokenisation might be 
> beneficial.
> Aims:
>  - Create and add a new file {{abb_PT.xml}} to _opennlp-tools/lang/pt_
>  - Add basic set of test cases
> Other:
>  - Confirm if European/Brazilian/African/Creole Portuguese have the same 
> abbreviations or if we need different languages...



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to