Je suis nouveau dans le traitement du langage naturel (NLP), je veux faire du marquage de la parole (POS), puis trouver une structure spécifique au sein d'un texte. Je pourrais gérer le marquage des points de vente à l'aide de Stanford-PNL, mais je ne sais pas comment extraire cette structure:extraire une structure linguistique basée sur la POS tagged phrase en utilisant Stanford nlp en JAVA
NN/NNS + IN + DT + NN/NNS/NNP/NNPS
public static void main(String args[]) throws Exception{
//input File
String contentFilePath = "";
//outputFile
String triplesFilePath = contentFilePath.substring(0, contentFilePath.length()-4)+"_postagg.txt";
//document to POS tagging
String content = getFileContent(contentFilePath);
Properties props = new Properties();
props.setProperty("annotators","tokenize, ssplit, pos");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// Annotate the document.
Annotation doc = new Annotation(content);
pipeline.annotate(doc);
// Annotate the document.
List<CoreMap> sentences = doc.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
for (CoreLabel token: sentence.get(CoreAnnotations.TokensAnnotation.class)) {
String word = token.get(CoreAnnotations.TextAnnotation.class);
// this is the POS tag of the token
String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class);
System.out.println(word + "/" + pos);
} }}}
Je viens de réaliser, que la balise POS pour un déterminant est "DT", pas "DET". J'ai corrigé ma réponse ci-dessous, ça marche maintenant. –