0

Je suis très nouveau dans le domaine de la PNL et je suis intéressé à détecter le poste/désignation/rôle avec leur nom, email, numéro de téléphone, etc J'ai essayé d'utiliser stanford PNL pour détecter les noms du texte. L'analyse du courrier électronique et du numéro de téléphone semble assez simple. Je suis incapable de détecter cependant la désignation d'un texte donné.Détecter la désignation des employés du texte en utilisant ner/nlp

Par exemple, voici quelques exemples d'échantillons de texte

1) directeur médical, le Dr. UN B. Ahmad, example1 @ example.com
Nom: Dr. UN B. Ahmad, Email: [email protected]

2) Sous-Doyens Académiques Prof. S. Antony [email protected]
Nom: Prof. S. Antony, Email: [email protected]

3) Sous-doyens universitaires & PG-Cell & Surg. Discipline Resident Trg. Programe, Mr. Sandeep
Nom: M. Sandeep, Email: aucun

4) Directeur, réseau, Robert Adams, example3 @ example.com, 9900131213
Nom: Robert Adams, Email: [email protected], Téléphone: 9900131213

Je ne suis pas intéressé par les algorithmes d'appariement de regex puisque la nature du texte est non déterministe. Ce qui m'intéresse est de savoir comment puis-je extraire les désignations ci-dessus du texte. Toute solution même au-delà de stanford NLP comme l'utilisation de nltk, lingpipe etc est très bien. Si j'utilise stanford PNL, comment puis-je construire un modèle de formation pour le même avec un type d'entité différente comme "POSITION" ou "DÉSIGNATION" et comment puis-je inclure ce modèle avec mes autres modèles (je cours stanford PNL dans le serveur mode).

+2

Vous devrez former votre propre modèle NER, en introduisant votre propre étiquette "DESIGNATION" dans votre ensemble d'entraînement. Jetez un oeil à leur documentaion. http://nlp.stanford.edu/software/crf-faq.shtml#a – meghamind

+0

pour former stanford parser pour «désignation» vous avez besoin de beaucoup de données d'entraînement pour que vous devez collecter des données plus volumineuses car une petite quantité de données peut ne pas donner vous corrigez les données –

Répondre

0

Essayez d'utiliser le fichier ci-dessous (de designation.rules.txt)

ENV.defaultStringPatternFlags = 2 

ner = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$NamedEntityTagAnnotation" } 
tokens = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$TokensAnnotation" } 

$Designation = (
    /CFO/| 
    /Director/| 
    /CEO/| 
    /Chief/| 
    /Executive/| 
    /Officer/| 
    /Vice/| 
    /President/| 
    /Senior/| 
    /Financial/ 
) 

ENV.defaults["ruleType"] = "tokens" 
ENV.defaults["stage"] = 1 
{ 
    pattern: ($Designation), 
    action: (Annotate($0, ner, "DESIGNATION")) 
} 

ENV.defaults["stage"] = 2 
{ 
    ruleType: "tokens", 
    pattern: (([ { ner:PERSON } ]) /has/ ([ { ner:DESIGNATION } ]+)), 
    result: Format("hasDesignation(%s,%s)",$1.word, Join(" ",$2.word)) 
} 

et utiliser le fichier ci-dessous Java pour générer

package org.itcookies.nlpdemo; 

import java.io.IOException; 
import java.io.PrintWriter; 
import java.util.List; 
import java.util.Properties; 

import edu.stanford.nlp.io.IOUtils; 
import edu.stanford.nlp.ling.CoreAnnotations; 
import edu.stanford.nlp.ling.CoreLabel; 
import edu.stanford.nlp.pipeline.Annotation; 
import edu.stanford.nlp.pipeline.StanfordCoreNLP; 
import edu.stanford.nlp.util.CoreMap; 

/** 
* Demo illustrating how to use TokensRegexAnnotator 
*/ 
public class TokensRegexAnnotatorDemo { 

    public static void main(String[] args) throws IOException { 
    PrintWriter out; 

    String rules; 
    if (args.length > 0) { 
     rules = args[0]; 
    } else { 
     rules = "org/itcookies/nlp/rules/designation.rules.txt"; 
    } 
    if (args.length > 2) { 
     out = new PrintWriter(args[2]); 
    } else { 
     out = new PrintWriter(System.out); 
    } 

    Properties properties = new Properties(); 
    properties.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,tokensregexdemo"); 
    properties.setProperty("customAnnotatorClass.tokensregexdemo", "edu.stanford.nlp.pipeline.TokensRegexAnnotator"); 
    properties.setProperty("tokensregexdemo.rules", rules); 
    StanfordCoreNLP pipeline = new StanfordCoreNLP(properties); 
    Annotation annotation; 
    if (args.length > 1) { 
     annotation = new Annotation(IOUtils.slurpFileNoExceptions(args[1])); 
    } else { 
     annotation = new Annotation("John is CEO of ITCookies"); 
    } 

    pipeline.annotate(annotation); 

    // An Annotation is a Map and you can get and use the various analyses individually. 
    out.println(); 
    // The toString() method on an Annotation just prints the text of the Annotation 
    // But you can see what is in it with other methods like toShorterString() 
    out.println("The top level annotation"); 
    out.println(annotation.toShorterString()); 
    List<CoreMap> sentences = annotation.get(CoreAnnotations.SentencesAnnotation.class); 

    for (CoreMap sentence : sentences) { 
     // NOTE: Depending on what tokensregex rules are specified, there are other annotations 
     //  that are of interest other than just the tokens and what we print out here 
     for (CoreLabel token:sentence.get(CoreAnnotations.TokensAnnotation.class)) { 
     // Print out words, lemma, ne, and normalized ne 
     String word = token.get(CoreAnnotations.TextAnnotation.class); 
     String lemma = token.get(CoreAnnotations.LemmaAnnotation.class); 
     String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); 
     String ne = token.get(CoreAnnotations.NamedEntityTagAnnotation.class); 
     String normalized = token.get(CoreAnnotations.NormalizedNamedEntityTagAnnotation.class); 
     if(ne.equals("DESIGNATION")) 
      out.println("token: " + "word="+word + ", lemma="+lemma + ", pos=" + pos + ", ne=" + ne + ", normalized=" + normalized); 
     } 
    } 
    out.flush(); 
    } 

} 

Et ci-dessous est la sortie

The top level annotation 
[Text=John is CEO of ITCookies Tokens=[John-1, is-2, CEO-3, of-4, ITCookies-5] Sentences=[John is CEO of ITCookies]] 
token: word=CEO, lemma=CEO, pos=NNP, ne=DESIGNATION, normalized=null 
Questions connexes