Code Monkey home page Code Monkey logo

ptoolner's Introduction

pToolNER

Ferramenta para trabalhar com Reconhecimento de Entidades Nomeadas em Português.

Exemplos

Como fazer a filtragem de Entidades Nomeadas permitindo apenas as EN do tipo PESSOA e LOCAL.

Aqui um corpus em formato CoNLL é carregado e em seguida um fitro deixa apenas as categorias PESSOA e LOCAL e substitui as demais categorias pela máscara 'O'.

pToolNER = PortugueseToolNER()

pToolNER.loadCorpusInCoNLLFormat(
                 inputFilePath='InputCorpus.txt',
                 setEncoding='utf8',
                 sepTokenTag=' ')

pToolNER.filterCoNLLCorpusByCategories(
                    acceptableLabels=['PER', 'LOC'],
                    maskForUnacceptLabel='O',
                    sepTokenTag=' ')

pToolNER.generateOutputFile(
               outputFileName='FilteredCorpus.txt',
               sentences=pToolNER.sentencesTokenAndLabels,
               outputFormat='CoNLL')

Como fazer a rotulção (sem uso de Máscara) de todos os arquivos .txt em uma pasta.

pToolNER = PortugueseToolNER()

pToolNER.loadNamedEntityModel('best-model.pt')

pToolNER.sequenceTaggingOnText(
               rootFolderPath='./PredictablesFiles',
               fileExtension='.txt',
               useTokenizer=True,
               maskNamedEntity=False,
               createOutputFile=True,
               outputFilePath='./TaggedTexts',
               outputFormat='plain',
               createOutputListSpans=True
               )

Como fazer rotulação de textos usando Máscara para categorias específicas de Entidades Nomeadas (EN).

Aqui as EN PESSOA e LOCAL serão substituídas por um único simbolo '[HIDDEN-INFO]'.

pToolNER = PortugueseToolNER()

pToolNER.loadNamedEntityModel('best-model.pt')

pToolNER.sequenceTaggingOnText(
               rootFolderPath='./PredictablesFiles',
               fileExtension='.txt',
               useTokenizer=True,
               maskNamedEntity=True,
               specialTokenToMaskNE='[HIDDEN-INFO]',
               sepTokenTag=' ',
               entitiesToMask=['B-PER', 'I-PER', 'B-LOC', 'I-LOC'],
               createOutputFile=True,
               outputFilePath='./TaggedTexts',
               outputFormat='plain',
               createOutputListSpans=True
               )

Como fazer rotulação de textos usando Máscara para EN e Lista auxiliar de EN.

pToolNER = PortugueseToolNER()

listStopNames = ['da', 'de', 'do', 'dos']
listNames = ['name name name', 'name', 'name name']

pToolNER.getUniqueNames(listNames, listStopNames)

pToolNER.loadNamedEntityModel('best-model.pt')

pToolNER.sequenceTaggingOnText(
               rootFolderPath='./PredictablesFiles',
               fileExtension='.txt',
               useTokenizer=True,
               maskNamedEntity=True,
               specialTokenToMaskNE='[HIDDEN-INFO]',
               sepTokenTag=' ',
               entitiesToMask=['B-PER', 'I-PER', 'B-LOC', 'I-LOC'],
               useAuxListNE=True,
               auxListNE=pToolNER.uniqueStringNames,
               createOutputFile=True,
               outputFilePath='./TaggedTexts',
               outputFormat='plain',
               createOutputListSpans=True
               )

Como fazer rotulação de sequencia de sentenças (On the fly) sem carregar arquivos de texto.

pToolNER = PortugueseToolNER()

listStopNames = ['da', 'de', 'do', 'dos']
listNames = ['name name name', 'name', 'name name']

pToolNER.getUniqueNames(listNames, listStopNames)

pToolNER.loadNamedEntityModel('best-model.pt')

pToolNER.sequenceTaggingOnTheFly(
			   textToPredict = 'Put Your Sentence Here.',
			   textId = 1,
			   useTokenizer=True,
			   useSentenceTokenize=True,
			   maskNamedEntity=True,
			   specialTokenToMaskNE='[HIDDEN-INFO]',
			   sepTokenTag=' ',
			   entitiesToMask=['B-PER', 'I-PER', 'B-LOC', 'I-LOC'],
			   useAuxListNE=True,
			   auxListNE=pToolNER.uniqueStringNames,
			   createOutputFile=True,
			   outputFilePath='./TaggedTexts',
			   outputFormat='plain',
			   createOutputListSpans=True
			   )

Anonimização de Entidades Nomeadas

Como fazer rotulação de sequencia de sentenças (On the fly) sem carregar arquivos de texto e lista auxiliar.

pToolNER = PortugueseToolNER()

pToolNER.loadNamedEntityModel('best-model.pt')

pToolNER.sequenceTaggingOnTheFly(
          textToPredict = 'Put Your Sentence Here.',
          textId = 1,
          useTokenizer=True,
          useSentenceTokenize=True,
          maskNamedEntity=True,
          specialTokenToMaskNE='[HIDDEN-INFO]',
          sepTokenTag=' ',
          entitiesToMask=['B-PER', 'I-PER', 'B-LOC', 'I-LOC'],
          useAuxListNE=False,
          createOutputFile=False,
	  createOutputListSpans=False
          )

ptoolner's People

Contributors

jneto04 avatar beatrizfagundes avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.