• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SeqClassifierFlags类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中edu.stanford.nlp.sequences.SeqClassifierFlags的典型用法代码示例。如果您正苦于以下问题:Java SeqClassifierFlags类的具体用法?Java SeqClassifierFlags怎么用?Java SeqClassifierFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SeqClassifierFlags类属于edu.stanford.nlp.sequences包,在下文中一共展示了SeqClassifierFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: BisequenceEmpiricalNERPrior

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public BisequenceEmpiricalNERPrior(String backgroundSymbol, Index<String> classIndex, Index<String> tagIndex, List<IN> doc, Pair<double[][], double[][]> matrices, SeqClassifierFlags flags) {
  this.flags = flags;
  this.classIndex = classIndex;
  this.tagIndex = tagIndex;
  this.backgroundSymbolIndex = classIndex.indexOf(backgroundSymbol);
  this.numClasses = classIndex.size();
  this.numTags = tagIndex.size();
  this.possibleValues = new int[numClasses];
  for (int i=0; i<numClasses; i++) {
    possibleValues[i] = i;
  }
  this.wordDoc = new ArrayList<String>(doc.size());
  for (IN w: doc) {
    wordDoc.add(w.get(CoreAnnotations.TextAnnotation.class));
  }
  entityMatrix = matrices.first();
  subEntityMatrix = matrices.second();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:19,代码来源:BisequenceEmpiricalNERPrior.java


示例2: loadClassifier

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
/** Load a classifier from the given Stream.
 *  <i>Implementation note: </i> This method <i>does not</i> close the
 *  Stream that it reads from.
 *
 *  @param ois The ObjectInputStream to load the serialized classifier from
 *
 *  @throws IOException If there are problems accessing the input stream
 *  @throws ClassCastException If there are problems interpreting the serialized data
 *  @throws ClassNotFoundException If there are problems interpreting the serialized data

 *  */
@SuppressWarnings("unchecked")
@Override
public void loadClassifier(ObjectInputStream ois, Properties props) throws ClassCastException, IOException, ClassNotFoundException {
  classifier = (LinearClassifier<String, String>) ois.readObject();
  flags = (SeqClassifierFlags) ois.readObject();
  featureFactory = (FeatureFactory) ois.readObject();

  if (props != null) {
    flags.setProperties(props);
  }
  reinit();

  classIndex = (Index<String>) ois.readObject();
  answerArrays = (Set<List<String>>) ois.readObject();

  knownLCWords = (Set<String>) ois.readObject();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:29,代码来源:CMMClassifier.java


示例3: main

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public static void main(String[] args) {
    String path = IntelConfig.DEPARTMENT_TRAIN_PROPERTY;
    Properties props = StringUtils.propFileToProperties(path);

    SeqClassifierFlags flags = new SeqClassifierFlags(props);
    CRFClassifier<CoreLabel> crf = new CRFClassifier<CoreLabel>(flags);
    crf.train();
    String modelPath = props.getProperty("serializeTo");
    crf.serializeClassifier(modelPath);
    System.out.println("Build model to " + modelPath);
}
 
开发者ID:intel-analytics,项目名称:InformationExtraction,代码行数:12,代码来源:TrainNerModel.java


示例4: loadClassifier

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public static CRFClassifier<CoreLabel> loadClassifier(String options) throws IllegalArgumentException {
  String[] inputFlags = options.split(" ");
  Properties props = StringUtils.argsToProperties(inputFlags);
  SeqClassifierFlags flags = new SeqClassifierFlags(props);
  CRFClassifier<CoreLabel> crfSegmenter = new CRFClassifier<>(flags);
  if(flags.loadClassifier == null) {
    throw new IllegalArgumentException("missing -loadClassifier flag for CRF preprocessor.");
  }
  crfSegmenter.loadClassifierNoExceptions(flags.loadClassifier, props);
  crfSegmenter.loadTagIndex();
  return crfSegmenter;
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:13,代码来源:CRFPreprocessor.java


示例5: CRFPostprocessor

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public CRFPostprocessor(Properties props) {
  // Currently, this class only supports one featureFactory.
  props.put("featureFactory", CRFPostprocessorFeatureFactory.class.getName());

  flags = new SeqClassifierFlags(props);
  classifier = new CRFClassifier<CoreLabel>(flags);
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:8,代码来源:CRFPostprocessor.java


示例6: train

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public void train(ListMatrix<ListMatrix<MapMatrix<String, String>>> listMatrix) throws Exception {
    List<List<CoreLabel>> sentenceList = new ArrayList<List<CoreLabel>>();
    for (ListMatrix<MapMatrix<String, String>> innerList : listMatrix) {
        List<CoreLabel> tokenList = new ArrayList<CoreLabel>();
        sentenceList.add(tokenList);
        for (MapMatrix<String, String> mapMatrix : innerList) {
            CoreLabel l = new CoreLabel();
            l.set(CoreAnnotations.TextAnnotation.class, mapMatrix.getAsString("Token"));
            l.set(CoreAnnotations.AnswerAnnotation.class, mapMatrix.getAsString("Class"));
            tokenList.add(l);
        }
    }

    SeqClassifierFlags flags = new SeqClassifierFlags();
    flags.maxLeft = 3;
    flags.useClassFeature = true;
    flags.useWord = true;
    flags.maxNGramLeng = 6;
    flags.usePrev = true;
    flags.useNext = true;
    flags.useDisjunctive = true;
    flags.useSequences = true;
    flags.usePrevSequences = true;
    flags.useTypeSeqs = true;
    flags.useTypeSeqs2 = true;
    flags.useTypeySequences = true;
    flags.wordShape = WordShapeClassifier.WORDSHAPECHRIS2;

    flags.useNGrams = true;
    crf = new CRFClassifier<CoreLabel>(flags);
    crf.train(sentenceList, null);
}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:33,代码来源:StanfordTagger.java


示例7: init

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public void init(SeqClassifierFlags flags) {
  super.init(flags);
  initGazette();
  if (flags.useDistSim) {
    initLexicon(flags);
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:8,代码来源:NERFeatureFactory.java


示例8: EmpiricalNERPriorBIO

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public EmpiricalNERPriorBIO(String backgroundSymbol, Index<String> classIndex, Index<String> tagIndex, List<IN> doc, Pair<double[][], double[][]> matrices, SeqClassifierFlags flags) {
  super(backgroundSymbol, classIndex, tagIndex, doc);
  entityMatrix = matrices.first();
  subEntityMatrix = matrices.second();
  this.flags = flags;
  ORGIndex = tagIndex.indexOf("ORG");
  LOCIndex = tagIndex.indexOf("LOC");
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:9,代码来源:EmpiricalNERPriorBIO.java


示例9: hiddenLayerOutput

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public double[] hiddenLayerOutput(double[][] inputLayerWeights, int[] nodeCliqueFeatures, SeqClassifierFlags aFlag, double[] featureVal) {
  int layerOneSize = inputLayerWeights.length;
  if (layerOneCache == null || layerOneSize != layerOneCache.length)
    layerOneCache = new double[layerOneSize];
  for (int i = 0; i < layerOneSize; i++) {
    double[] ws = inputLayerWeights[i];
    double lOneW = 0;
    double dotProd = 0;
    for (int m = 0; m < nodeCliqueFeatures.length; m++) {
      dotProd = ws[nodeCliqueFeatures[m]];
      if (featureVal != null)
        dotProd *= featureVal[m];
      lOneW += dotProd;
    }
    layerOneCache[i] = lOneW;
  }
  if (!aFlag.useHiddenLayer)
    return layerOneCache;
    
  // transform layer one through hidden
  if (hiddenLayerCache == null || layerOneSize != hiddenLayerCache.length)
    hiddenLayerCache = new double[layerOneSize];
  for (int i = 0; i < layerOneSize; i++) {
    if (aFlag.useSigmoid) {
      hiddenLayerCache[i] = sigmoid(layerOneCache[i]);
    } else {
      hiddenLayerCache[i] = Math.tanh(layerOneCache[i]);
    }
  }
  return hiddenLayerCache;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:32,代码来源:NonLinearCliquePotentialFunction.java


示例10: CRFNonLinearLogConditionalObjectiveFunction

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
CRFNonLinearLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures, double[][][][] featureVal) {
  this.window = window;
  this.classIndex = classIndex;
  this.numClasses = classIndex.size();
  this.labelIndices = labelIndices;
  this.data = data;
  this.featureVal = featureVal;
  this.flags = flags;
  this.map = map;
  this.labels = labels;
  this.prior = getPriorType(flags.priorType);
  this.backgroundSymbol = flags.backgroundSymbol;
  this.sigma = flags.sigma;
  this.outputLayerSize = numClasses;
  this.numHiddenUnits = flags.numHiddenUnits;
  if (flags.arbitraryInputLayerSize != -1)
    this.inputLayerSize = flags.arbitraryInputLayerSize;
  else
    this.inputLayerSize = numHiddenUnits * numClasses;
  this.numNodeFeatures = numNodeFeatures;
  this.numEdgeFeatures = numEdgeFeatures;
  System.err.println("numOfEdgeFeatures: " + numEdgeFeatures);
  this.useOutputLayer = flags.useOutputLayer;
  this.useHiddenLayer = flags.useHiddenLayer;
  this.useSigmoid = flags.useSigmoid;
  this.docWindowLabels = new int[data.length][];
  if (!useOutputLayer) {
    System.err.println("Output layer not activated, inputLayerSize must be equal to numClasses, setting it to " + numClasses);
    this.inputLayerSize = numClasses;
  } else if (flags.softmaxOutputLayer && !(flags.sparseOutputLayer || flags.tieOutputLayer)) {
    throw new RuntimeException("flags.softmaxOutputLayer == true, but neither flags.sparseOutputLayer or flags.tieOutputLayer is true");
  }
  empiricalCounts();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:35,代码来源:CRFNonLinearLogConditionalObjectiveFunction.java


示例11: NonLinearSecondOrderCliquePotentialFunction

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public NonLinearSecondOrderCliquePotentialFunction(double[][] inputLayerWeights4Edge, double[][] outputLayerWeights4Edge, double[][] inputLayerWeights, double[][] outputLayerWeights, SeqClassifierFlags flags) {
  this.inputLayerWeights4Edge = inputLayerWeights4Edge;
  this.outputLayerWeights4Edge = outputLayerWeights4Edge;
  this.inputLayerWeights = inputLayerWeights;
  this.outputLayerWeights = outputLayerWeights;
  this.flags = flags;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:8,代码来源:NonLinearSecondOrderCliquePotentialFunction.java


示例12: CRFNonLinearSecondOrderLogConditionalObjectiveFunction

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
CRFNonLinearSecondOrderLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, int prior, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures) {
  this.window = window;
  this.classIndex = classIndex;
  this.numClasses = classIndex.size();
  this.labelIndices = labelIndices;
  this.data = data;
  this.flags = flags;
  this.map = map;
  this.labels = labels;
  this.prior = prior;
  this.backgroundSymbol = flags.backgroundSymbol;
  this.sigma = flags.sigma;
  this.outputLayerSize = numClasses;
  this.outputLayerSize4Edge = numClasses * numClasses;
  this.numHiddenUnits = flags.numHiddenUnits;
  this.inputLayerSize = numHiddenUnits * numClasses;
  this.inputLayerSize4Edge = numHiddenUnits * numClasses * numClasses;
  this.numNodeFeatures = numNodeFeatures;
  this.numEdgeFeatures = numEdgeFeatures;
  this.useOutputLayer = flags.useOutputLayer;
  this.useHiddenLayer = flags.useHiddenLayer;
  this.useSigmoid = flags.useSigmoid;
  this.docWindowLabels = new int[data.length][];
  if (!useOutputLayer) {
    System.err.println("Output layer not activated, inputLayerSize must be equal to numClasses, setting it to " + numClasses);
    this.inputLayerSize = numClasses;
    this.inputLayerSize4Edge = numClasses * numClasses;
  } else if (flags.softmaxOutputLayer && !(flags.sparseOutputLayer || flags.tieOutputLayer)) {
    throw new RuntimeException("flags.softmaxOutputLayer == true, but neither flags.sparseOutputLayer or flags.tieOutputLayer is true");
  }
  // empiricalCounts();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:33,代码来源:CRFNonLinearSecondOrderLogConditionalObjectiveFunction.java


示例13: hiddenLayerOutput

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public static double[] hiddenLayerOutput(double[][] inputLayerWeights, int[] nodeCliqueFeatures, SeqClassifierFlags aFlag, double[] featureVal) {
  int layerOneSize = inputLayerWeights.length;
  double[] layerOne = new double[layerOneSize];
  for (int i = 0; i < layerOneSize; i++) {
    double[] ws = inputLayerWeights[i];
    double lOneW = 0;
    double dotProd = 0;
    for (int m = 0; m < nodeCliqueFeatures.length; m++) {
      dotProd = ws[nodeCliqueFeatures[m]];
      if (featureVal != null)
        dotProd *= featureVal[m];
      lOneW += dotProd;
    }
    layerOne[i] = lOneW;
  }
  // transform layer one through hidden
  double[] hiddenLayer = new double[layerOneSize];
  for (int i = 0; i < layerOneSize; i++) {
    if (aFlag.useHiddenLayer) {
      if (aFlag.useSigmoid) {
        hiddenLayer[i] = sigmoid(layerOne[i]);
      } else {
        hiddenLayer[i] = Math.tanh(layerOne[i]);
      }
    } else {
      hiddenLayer[i] = layerOne[i];
    }
  }
  return hiddenLayer;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:31,代码来源:NonLinearCliquePotentialFunction.java


示例14: CRFNonLinearLogConditionalObjectiveFunction

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
CRFNonLinearLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures, double[][][][] featureVal) {
  this.window = window;
  this.classIndex = classIndex;
  this.numClasses = classIndex.size();
  this.labelIndices = labelIndices;
  this.data = data;
  this.featureVal = featureVal;
  this.flags = flags;
  this.map = map;
  this.labels = labels;
  this.prior = getPriorType(flags.priorType);
  this.backgroundSymbol = flags.backgroundSymbol;
  this.sigma = flags.sigma;
  this.priorL1Lambda = flags.priorL1Lambda;
  this.outputLayerSize = numClasses;
  this.numHiddenUnits = flags.numHiddenUnits;
  if (flags.arbitraryInputLayerSize != -1)
    this.inputLayerSize = flags.arbitraryInputLayerSize;
  else
    this.inputLayerSize = numHiddenUnits * numClasses;
  this.numNodeFeatures = numNodeFeatures;
  this.numEdgeFeatures = numEdgeFeatures;
  System.err.println("numOfEdgeFeatures: " + numEdgeFeatures);
  this.useOutputLayer = flags.useOutputLayer;
  this.useHiddenLayer = flags.useHiddenLayer;
  this.useSigmoid = flags.useSigmoid;
  this.docWindowLabels = new int[data.length][];
  if (!useOutputLayer) {
    System.err.println("Output layer not activated, inputLayerSize must be equal to numClasses, setting it to " + numClasses);
    this.inputLayerSize = numClasses;
  } else if (flags.softmaxOutputLayer && !(flags.sparseOutputLayer || flags.tieOutputLayer)) {
    throw new RuntimeException("flags.softmaxOutputLayer == true, but neither flags.sparseOutputLayer or flags.tieOutputLayer is true");
  }
  empiricalCounts();
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:36,代码来源:CRFNonLinearLogConditionalObjectiveFunction.java


示例15: init

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public void init(SeqClassifierFlags flags) {
  super.init(flags);
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:4,代码来源:CRFPostprocessorFeatureFactory.java


示例16: init

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
@Override
public void init(SeqClassifierFlags flags) {}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:3,代码来源:ProcessorTools.java


示例17: StanfordTagger

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public StanfordTagger(File file) throws Exception {
    crf = new CRFClassifier<CoreLabel>(new SeqClassifierFlags());
    crf.loadClassifierNoExceptions(file);
}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:5,代码来源:StanfordTagger.java


示例18: NonLinearCliquePotentialFunction

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public NonLinearCliquePotentialFunction(double[][] linearWeights, double[][] inputLayerWeights, double[][] outputLayerWeights, SeqClassifierFlags flags) {
  this.linearWeights = linearWeights;
  this.inputLayerWeights = inputLayerWeights;
  this.outputLayerWeights = outputLayerWeights;
  this.flags = flags;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:7,代码来源:NonLinearCliquePotentialFunction.java


示例19: hiddenLayerOutput

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
public double[] hiddenLayerOutput(double[][] inputLayerWeights, int[] nodeCliqueFeatures, SeqClassifierFlags aFlag, double[] featureVal, int cliqueSize) {
  double[] layerCache = null;
  double[] hlCache = null;
  int layerOneSize = inputLayerWeights.length;
  if (cliqueSize > 1) {
    if (layerOneCache4Edge == null || layerOneSize != layerOneCache4Edge.length)
      layerOneCache4Edge = new double[layerOneSize];
    layerCache = layerOneCache4Edge;
  } else {
    if (layerOneCache == null || layerOneSize != layerOneCache.length)
      layerOneCache = new double[layerOneSize];
    layerCache = layerOneCache;
  }
  for (int i = 0; i < layerOneSize; i++) {
    double[] ws = inputLayerWeights[i];
    double lOneW = 0;
    double dotProd = 0;
    for (int m = 0; m < nodeCliqueFeatures.length; m++) {
      dotProd = ws[nodeCliqueFeatures[m]];
      if (featureVal != null)
        dotProd *= featureVal[m];
      lOneW += dotProd;
    }
    layerCache[i] = lOneW;
  }
  if (!aFlag.useHiddenLayer)
    return layerCache;
    
  // transform layer one through hidden
  if (cliqueSize > 1) {
    if (hiddenLayerCache4Edge == null || layerOneSize != hiddenLayerCache4Edge.length)
      hiddenLayerCache4Edge = new double[layerOneSize];
    hlCache = hiddenLayerCache4Edge;
  } else {
    if (hiddenLayerCache == null || layerOneSize != hiddenLayerCache.length)
      hiddenLayerCache = new double[layerOneSize];
    hlCache = hiddenLayerCache;
  }
  for (int i = 0; i < layerOneSize; i++) {
    if (aFlag.useSigmoid) {
      hlCache[i] = sigmoid(layerCache[i]);
    } else {
      hlCache[i] = Math.tanh(layerCache[i]);
    }
  }
  return hlCache;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:48,代码来源:NonLinearSecondOrderCliquePotentialFunction.java


示例20: CMMClassifier

import edu.stanford.nlp.sequences.SeqClassifierFlags; //导入依赖的package包/类
protected CMMClassifier() {
  super(new SeqClassifierFlags());
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:4,代码来源:CMMClassifier.java



注:本文中的edu.stanford.nlp.sequences.SeqClassifierFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GMSSRootSig类代码示例发布时间:2022-05-22
下一篇:
Java FunctionRegistry类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap