J'essaye de former le classificateur de Stanford NER pour identifier des choses spécifiques dans des bases de données de texte. J'ai fait un nouveau fichier .prop et un dossier de formation, et J'obtiens des résultats, mais ce sont les résultats par défaut que j'obtiendrais si je courais le classificateur sans entraînement. Tout ce que je peux faire pour adapter cela?Stanford NER n'utilisera pas mon fichier d'entraînement, mais utilise par défaut
Ceci est mon code:
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;
import edu.stanford.nlp.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Properties;public class NLP_train {
public static void main(String[] args) throws IOException {
Properties props = StringUtils.propFileToProperties("C:/Users/Admin/Desktop/trainingfile.prop");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
// read some text in the text variable
File inputFile = new File("C:/Users/Admin/Desktop/target.txt");
// create an empty Annotation just with the given text
Annotation document = new Annotation(IOUtils.slurpFileNoExceptions(inputFile));
// run all Annotators on this text
pipeline.annotate(document);
List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
for (CoreMap sentence : sentences) {
// traversing the words in the current sentence
// a CoreLabel is a CoreMap with additional token-specific methods
for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) {
// this is the text of the token
String word = token.get(CoreAnnotations.TextAnnotation.class);
// this is the POS tag of the token
String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class);
// this is the NER label of the token
String ne = token.get(CoreAnnotations.NamedEntityTagAnnotation.class);
System.out.println(String.format("Print: word: [%s] pos: [%s] ne: [%s]", word, pos, ne));
}
}
}
}
Voici mon fichier .prop:
trainFile = C: /Users/Admin/Desktop/trainingfile.tsv
serializeTo = C: /Users/Admin/Desktop/ner-model.ser.gz
map = mot = 0, réponse = 1
useClassFeature = true
useWord = true
useNGrams = true
noMidNGrams = true
useDisjunctive = true
maxNGramLeng = 6
usePrev = true
UseNeXT = true
useSequences = true
usePrevSequences = true
maxLeft = 1
4 suivant accord avec la forme de texte comporte
useTypeSeqs = true
useTypeSeqs2 = true
useTypeySequences = true
wordShape = chris2useLC
Et un extrait de mon dossier de formation:
Le 0
Radar Type
347G Radar
`` 0
riz 0
Bowl 0
'' 0