加载特征值 //11:*6:_x-1/的,

@param featureIndex

@param br
@return
@throws Exception
966464
private List<Pair<String, String>> loadFeatureName(Map<String, Integer> featureIndex, BufferedReader br)
                    throws Exception {
        String temp = br.readLine();// #qrk#num
        int featureNum = ObjConver.getIntValue(StringUtil.matcherFirst("\\d+", temp)); // 找到特征个数

        List<Pair<String, String>> featureNames = new ArrayList<>();

        for (int i = 0; i < featureNum; i++) {
            temp = br.readLine();

            String[] split = temp.split(":");

            if (split.length == 2) {
                featureNames.add(Pair.with(split[1], ""));
                continue;
            } else {

                String name = split[2];

                if (split.length > 3) {
                    for (int j = 3; j < split.length; j++) {
                        name += ":" + split[j];
                    }
                }

                // 去掉最后的空格
                name = name.substring(0, name.length() - 1);

                int lastFeatureId = featureIndex.get(split[1]);

                if ("/".equals(name)) {
                    name = "//";
                }

                if (name.contains("//")) {
                    name = name.replaceAll("//", "/XIEGANG/");
                }
                String featureName = toFeatureName(name.trim().split("/"), lastFeatureId);

                featureNames.add(Pair.with(split[1], featureName));

            }
        }

        return featureNames;

    }
958314
@Override
  public Result<MZXMLIndexElement> buildIndex(final IndexBuilder.Info info) throws Exception {
    Result<MZXMLIndexElement> result = new IndexBuilder.Result<>(info);

    int numOpeningScanTagsFound = 0;
    vars.reset();

    XMLStreamReaderImpl reader = (pool == null) ? new XMLStreamReaderImpl() : pool.borrowObject();
    try {
      reader.setInput(info.is, StandardCharsets.UTF_8.name());
      LogHelper.setJavolutionLogLevelFatal();

      final XMLStreamReaderImpl.LocationImpl location = reader.getLocation();
      int eventType = XMLStreamConstants.END_DOCUMENT;
      CharArray localName, attr;
      Attributes attrs;
      do {
        // Read the next XML element
        try {
          eventType = reader.next();
        } catch (XMLStreamException e) {

          if (e instanceof XMLUnexpectedEndTagException) {
            // it's ok to have unexpected closing tags
            eventType = reader.getEventType();
          } else if (e instanceof XMLUnexpectedEndOfDocumentException) {
            // as we're reading arbitrary chunks of file, we will almost always finish parsing by hitting this condition
            break;
          } else {
            throw new FileParsingException(e);
          }
        }

        // Process the read event
        switch (eventType) {

          case XMLStreamConstants.START_ELEMENT:
            localName = reader.getLocalName();
            attrs = reader.getAttributes();

            if (localName.contentEquals(MZXMLMultiSpectraParser.TAG.SCAN.name)) {
              if (vars.offsetLo != null) {
                // this means we've encountered nested Spectrum tags
                long lastStartTagPos = location.getLastStartTagPos();
                vars.length = (int) (vars.offsetLo - lastStartTagPos);
                addAndFlush(result, info.offsetInFile);
              }

              //tagScanStart(reader);
              vars.offsetLo = location.getLastStartTagPos();
              try {
                vars.scanNumRaw = attrs.getValue(MZXMLMultiSpectraParser.ATTR.SCAN_NUM.name)
                    .toInt();
              } catch (NumberFormatException e) {
                throw new FileParsingException("Malformed scan number while building index", e);
              }

            }
            break;

          case XMLStreamConstants.CHARACTERS:
            break;

          case XMLStreamConstants.END_ELEMENT:
            localName = reader.getLocalName();

            if (localName.contentEquals(MZXMLMultiSpectraParser.TAG.SCAN.name)) {
              vars.offsetHi = location.getTotalCharsRead();
              addAndFlush(result, info.offsetInFile);
            }

            break;
        }
      } while (eventType != XMLStreamConstants.END_DOCUMENT);

    } finally {
      addAndFlush(result, info.offsetInFile);

      // we need to return the reaer to the pool, if we borrowed it from there
      if (pool != null && reader != null) {
        pool.returnObject(reader);
      }
    }

    return result;
  }
124729
@Override
    public void setIndex(boolean b)
    {
        if (b)
        {
            assert safe == null;
            safe = type;
            type = Typ.Int;
        }
        else
        {
            assert type.getKind() == TypeKind.INT;
            assert safe != null;
            type = safe;
            safe = null;
        }
    }
834788
private void loadFeatureWeight(BufferedReader br, int[] statusCoven,
                    TreeMap<Integer, Pair<String, String>> featureNames) throws Exception {

        featureTree = new SmartForest<float[]>();

        int tag = 0; // 赏析按标签为用来转换

        int len = 0; // 权重数组的大小

        String name = null; // 特征名称

        float[] tempW = null; // 每一个特征的权重

        String temp = null;

        for (Pair<String, String> pair : featureNames.values()) {

            char fc = Character.toUpperCase(pair.getValue0().charAt(0));

            len = fc == 'B' ? Config.TAG_NUM * Config.TAG_NUM
                            : fc == 'U' ? Config.TAG_NUM
                                            : fc == '*' ? (Config.TAG_NUM + Config.TAG_NUM * Config.TAG_NUM) : 0;

            if (len == 0) {
                throw new Exception("unknow feature type " + pair.getValue0());
            }

            if (fc == 'B') { // 特殊处理转换特征数组
                for (int i = 0; i < len; i++) {
                    temp = br.readLine();
                    int from = statusCoven[i / Config.TAG_NUM];
                    int to = statusCoven[i % Config.TAG_NUM];
                    status[from][to] = ObjConver.getFloatValue(temp);
                }

            } else {

                name = pair.getValue1();

                tempW = new float[len];

                for (int i = 0; i < len; i++) {
                    temp = br.readLine();
                    tag = statusCoven[i];
                    tempW[tag] = ObjConver.getFloatValue(temp);
                }
                this.featureTree.add(name, tempW); // 将特征增加到特征🌲中

                // printFeatureTree(name, tempW);
            }

        }

    }
1130980
public static int indexOf(CharSequence seq, CharSequence pattern, int fromIndex)
    {
        return indexOf(seq, pattern, (int a, int b)->{return a==b;}, fromIndex);
    }
729580
function(featureId) {
        var id = Number(featureId.split("_").pop()) + 1; // zero for no feature
        if (id >= 16777216) {
            this.hitOverflow = id - 16777215;
            id = id % 16777216 + 1;
        }
        var hex = "000000" + id.toString(16);
        var len = hex.length;
        hex = "#" + hex.substring(len-6, len);
        return hex;
    }
899036
public boolean loadDictionary(BufferedReader br, int termIndex, int countIndex) {
    if (br == null) {
      return false;
    }

    SuggestionStage staging = new SuggestionStage(16384);
    try {
      for (String line; (line = br.readLine()) != null; ) {
        String[] lineParts = line.split("\\s");
        if (lineParts.length >= 2) {
          String key = lineParts[termIndex];
          long count;
          try {
            count = Long.parseLong(lineParts[countIndex]);
            //count = Long.parseUnsignedLong(lineParts[countIndex]);
            createDictionaryEntry(key, count, staging);
          } catch (NumberFormatException ex) {
            System.out.println(ex.getMessage());
          }
        }
      }
    } catch (IOException ex) {
      System.out.println(ex.getMessage());
    }
    if (this.deletes == null) {
      this.deletes = new HashMap<>(staging.deleteCount());
    }
    commitStaged(staging);
    return true;
  }
78012
Feature nextEFeature() {
	Feature eF = (Feature)eFeatures.get(eFeatureIdx);
	eFeatureIdx++;
	return eF;
    }
667731
private void handleSequenceAnnotation(String seqName, String featureName, String value) {
		if (featureName.equals(GS_ACCESSION_NUMBER)) {
			stockholmStructure.addGSAccessionNumber(seqName, value);
		} else if (featureName.equals(GS_DESCRIPTION)) {
			stockholmStructure.addGSDescription(seqName, value);
		} else if (featureName.equals(GS_DATABASE_REFERENCE)) {
			stockholmStructure.addGSdbReference(seqName, value);
		} else if (featureName.equals(GS_ORGANISM_SPECIES)) {
			stockholmStructure.addGSOrganismSpecies(seqName, value);
		} else if (featureName.equals(GS_ORGANISM_CLASSIFICATION)) {
			stockholmStructure.addGSOrganismClassification(seqName, value);
		} else if (featureName.equals(GS_LOOK)) {
			stockholmStructure.addGSLook(seqName, value);
		} else {
			// unknown feature
			logger.warn("Unknown Sequence Feature [{}].\nPlease contact the Biojava team.", featureName);
		}
	}
1216707
public final void ruleXExpression() throws RecognitionException {

        		int stackSize = keepStackSize();
        	
        try {
            // InternalXbase.g:71:2: ( ( ruleXAssignment ) )
            // InternalXbase.g:72:2: ( ruleXAssignment )
            {
            // InternalXbase.g:72:2: ( ruleXAssignment )
            // InternalXbase.g:73:3: ruleXAssignment
            {
            if ( state.backtracking==0 ) {
               before(grammarAccess.getXExpressionAccess().getXAssignmentParserRuleCall()); 
            }
            pushFollow(FOLLOW_2);
            ruleXAssignment();

            state._fsp--;
            if (state.failed) return ;
            if ( state.backtracking==0 ) {
               after(grammarAccess.getXExpressionAccess().getXAssignmentParserRuleCall()); 
            }

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {

            	restoreStackSize(stackSize);

        }
        return ;
    }
131526
def feature(self, index):
        
        if index < 0 or index >= self.num_features_:
            raise ValueError('Index %d out of range' %(index))
        return self.features_[index]
176157
public FeatureShape getFeatureShape(String database, String table, long featureId) {
        Map<Long, FeatureShape> featureIds = getFeatureIds(database, table);
        FeatureShape featureShape = getFeatureShape(featureIds, featureId);
        return featureShape;
    }
203744
public void FeatureInit(String str, Map cpStr2Int, Map lbStr2Int) {
	StringTokenizer strTok = new StringTokenizer(str, " \t\r\n");
	// <label> <cp> <idx> <wgt>
	
	int len = strTok.countTokens();
	if (len != 4) {
	    return;
	}
	
	String labelStr = strTok.nextToken();
	String cpStr = strTok.nextToken();
	int idx = Integer.parseInt(strTok.nextToken());
	float val = 1;
	double wgt = Double.parseDouble(strTok.nextToken());
	
	Integer labelInt = (Integer)lbStr2Int.get(labelStr);
	Integer cpInt = (Integer)cpStr2Int.get(cpStr);
	FeatureInit(labelInt.intValue(), cpInt.intValue());
	
	this.idx = idx;
	this.val = val;
	this.wgt = wgt;
    }
945969
public void update(int[] goldIndex, int[] predictIndex)
    {
        for (int i = 0; i < goldIndex.length; ++i)
        {
            if (goldIndex[i] == predictIndex[i])
                continue;
            else // 预测与答案不一致
            {
                parameter[goldIndex[i]]++; // 奖励正确的特征函数（将它的权值加一）
                if (predictIndex[i] >= 0 && predictIndex[i] < parameter.length)
                    parameter[predictIndex[i]]--; // 惩罚招致错误的特征函数（将它的权值减一）
                else
                {
                    throw new IllegalArgumentException("更新参数时传入了非法的下标");
                }
            }
        }
    }
432327
public void addRule( RuleWrapper addRule ) {
        Rule rule = addRule.getRule();
        featureTypeStyle.rules().add(rule);
        rulesWrapperList.add(addRule);
    }
1371135
@Override
    public double[] feature(T[] x) {
        double[] bag = new double[features.size()];

        if (binary) {
            for (T word : x) {
                Integer f = features.get(word);
                if (f != null) {
                    bag[f] = 1.0;
                }
            }
        } else {
            for (T word : x) {
                Integer f = features.get(word);
                if (f != null) {
                    bag[f]++;
                }
            }
        }

        return bag;
    }
150004
public static void writeBinary(String featuresFileName, double[][] features) throws Exception {
		DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(
				featuresFileName)));
		for (int i = 0; i < features.length; i++) {
			for (int j = 0; j < features[i].length; j++) {
				out.writeDouble(features[i][j]);
			}
		}
		out.close();
	}