移除词典中的短语结构
@param phrasePath
@param dicPath
331793
public static void removePhraseFromDic(String phrasePath, String dicPath) {
        try(Stream<String> phrases = Files.lines(Paths.get(phrasePath), Charset.forName("utf-8"));
            Stream<String> words = Files.lines(Paths.get(dicPath), Charset.forName("utf-8"))){
            Set<String> set = new HashSet<>();
            phrases.forEach(phrase -> {
                String[] attr = phrase.split("=");
                if (attr != null && attr.length == 2) {
                    set.add(attr[0]);
                }
            });
            List<String> list = new ArrayList<>();
            AtomicInteger len = new AtomicInteger();
            words.forEach(word -> {
                len.incrementAndGet();
                if(!set.contains(word)){
                    list.add(word);
                }
            });
            set.clear();
            Files.write(Paths.get(dicPath), list, Charset.forName("utf-8"));
            LOGGER.info("移除短语结构数目："+(len.get() - list.size()));
        }catch(Exception e){
            LOGGER.error("移除短语结构失败：", e);
        }
    }
123237
public static LabelAwareSentenceIterator createWithPath(String path) throws Exception {
        return new LabelAwareUimaSentenceIterator(null, path,
                        new UimaResource(AnalysisEngineFactory.createEngine(AnalysisEngineFactory
                                        .createEngineDescription(TokenizerAnnotator.getDescription(),
                                                        SentenceAnnotator.getDescription()))));
    }
25212
public static String applySpecialPaths(String path) throws IllegalArgumentException {
        List<String> tokens = getTokens(path);
        if (tokens == null) { return null; }
        int i = 0;
        for (int j = 0; j < tokens.size(); j++) {
            String token = tokens.get(j);
            if (isCurrentToken(token)) { continue; } else if (isReverseToken(token)) { i--; } else { tokens.set(i++, token); }
            if (i < 0) {
                throw VFSMessages.MESSAGES.onRootPath();
            }
        }
        return getRemainingPath(tokens, 0, i);
    }
10916
public IDependencyParser setDeprelTranslater(String deprelTranslatorPath)
    {
        deprelTranslater = GlobalObjectPool.get(deprelTranslatorPath);
        if (deprelTranslater != null) return this;

        IOUtil.LineIterator iterator = new IOUtil.LineIterator(deprelTranslatorPath);
        deprelTranslater = new TreeMap<String, String>();
        while (iterator.hasNext())
        {
            String[] args = iterator.next().split("\\s");
            deprelTranslater.put(args[0], args[1]);
        }
        if (deprelTranslater.size() == 0)
        {
            deprelTranslater = null;
        }
        GlobalObjectPool.put(deprelTranslatorPath, deprelTranslater);

        return this;
    }
306750
public static CWSEvaluator.Result evaluate(Segment segment, String outputPath, String goldFile, String dictPath) throws IOException
    {
        IOUtil.LineIterator lineIterator = new IOUtil.LineIterator(goldFile);
        BufferedWriter bw = IOUtil.newBufferedWriter(outputPath);
        for (String line : lineIterator)
        {
            List<Term> termList = segment.seg(line.replaceAll("\\s+", "")); // 一些testFile与goldFile根本不匹配，比如MSR的testFile有些行缺少单词，所以用goldFile去掉空格代替
            int i = 0;
            for (Term term : termList)
            {
                bw.write(term.word);
                if (++i != termList.size())
                    bw.write("  ");
            }
            bw.newLine();
        }
        bw.close();
        CWSEvaluator.Result result = CWSEvaluator.evaluate(goldFile, outputPath, dictPath);
        return result;
    }
1176702
public void count(String path,boolean b) throws IOException{

		HashMap<String, Integer> wordsFreq = new HashMap<String, Integer>();
		HashMap<Integer, Integer> lensFreq = new HashMap<Integer, Integer>();
		HashMap<String, Integer> posFreq = new HashMap<String, Integer>();
		HashMap<String, Integer> relsFreq = new HashMap<String, Integer>();
		HashMap<String, HashSet<String>> wordsPOS = new HashMap<String, HashSet<String>>();
		
		int total = 0;
		int totalsent = 0;
		Iterator<FNLPDoc> dit = docs.iterator();
		while(dit.hasNext()){
			FNLPDoc doc = dit.next();
			Iterator<FNLPSent> sit = doc.sentences.iterator();
			while(sit.hasNext()){
				FNLPSent sent = sit.next();
				totalsent++;
				for(int i=0;i<sent.words.length;i++){
					total++;
					String w = sent.words[i];
					int len = w.length();
					String pos = sent.tags[i];
					if(!pos.equals("专有名"))
						continue;
					String rels = sent.relations[i];
//					if(len > 20){
//						System.out.println(w);						
//					}
					
					if (posFreq.containsKey(pos)) {
						posFreq.put(pos, posFreq.get(pos) + 1);
					} else {
						posFreq.put(pos, 1);
					}

					if (lensFreq.containsKey(len)) {
						lensFreq.put(len, lensFreq.get(len) + 1);
					} else {
						lensFreq.put(len, 1);
					}

					if (wordsFreq.containsKey(w)) {
						wordsFreq.put(w, wordsFreq.get(w) + 1);
						
					} else {
						wordsFreq.put(w, 1);						
					}
					
					if (wordsPOS.containsKey(w)) {
						wordsPOS.get(w).add(pos);						
					} else {
						HashSet<String> posset = new HashSet<String>();
						posset.add(pos);
						wordsPOS.put(w, posset);			
					}
					
					
					
					if (relsFreq.containsKey(rels)) {
						relsFreq.put(rels, relsFreq.get(rels) + 1);
					} else {
						relsFreq.put(rels, 1);
					}
				}
			}
		}
		System.out.println("总字数："+total);
		System.out.println("总句数："+totalsent);
		List<Entry> sortedwordsFreq = MyCollection.sort(wordsFreq);		
		MyCollection.write(sortedwordsFreq, path+"/wc.txt", b);
		
		List<Entry> sortedposFreq = MyCollection.sort(posFreq);		
		MyCollection.write(sortedposFreq, path+"/pos.txt", b);
		
		List<Entry> sortedlrelsFreq = MyCollection.sort(relsFreq);
		MyCollection.write(sortedlrelsFreq, path+"/relations.txt", b);

		List<Entry> sortedlensFreq = MyCollection.sort(lensFreq);
		MyCollection.write(sortedlensFreq, path+"/lc.txt", b);
		
		MyCollection.write(wordsPOS, path+"/wordpos.txt");
	}
629445
public static boolean isProperPrefixPath(String firstPath, String secondPath) {

        firstPath = CmsStringUtil.joinPaths(firstPath, "/");
        secondPath = CmsStringUtil.joinPaths(secondPath, "/");
        return secondPath.startsWith(firstPath) && !firstPath.equals(secondPath);

    }
1296579
public JCRPath parseJCRPath(String path) throws RepositoryException
   {
      if (isAbsPathParseable(path))
      {
         return parseAbsPath(path);
      }
      else
      {
         return parseRelPath(path);
      }
   }
1004202
private static String resolveSibling(String fromPath, String toPath) {
    // If the destination is an absolute path, nothing to do.
    if (toPath.startsWith("/")) {
      return toPath;
    }

    List<String> fromPathParts = new ArrayList<>(Arrays.asList(fromPath.split("/")));
    List<String> toPathParts = new ArrayList<>(Arrays.asList(toPath.split("/")));
    if (!fromPathParts.isEmpty()) {
      fromPathParts.remove(fromPathParts.size() - 1);
    }

    while (!fromPathParts.isEmpty() && !toPathParts.isEmpty()) {
      if (toPathParts.get(0).equals(".")) {
        toPathParts.remove(0);
      } else if (toPathParts.get(0).equals("..")) {
        toPathParts.remove(0);
        fromPathParts.remove(fromPathParts.size() - 1);
      } else {
        break;
      }
    }

    fromPathParts.addAll(toPathParts);
    return String.join("/", fromPathParts);
  }
73804
protected function copyTemplateDirectoryAndGetPath(
        string $templatePath,
        string $destPath
    ): string {
        return $this->pathHelper->copyTemplateDirectoryAndGetPath(
            $this->pathToProjectRoot,
            $templatePath,
            $destPath
        );
    }
720716
private void parseRelativePathExpr() throws TTXPathException {

        parseStepExpr();

        while (mToken.getType() == TokenType.SLASH || mToken.getType() == TokenType.DESC_STEP) {

            if (is(TokenType.DESC_STEP, true)) {
                final AbsAxis mAxis = new DescendantAxis(getTransaction(), true);

                mPipeBuilder.addStep(mAxis);
            } else {
                // in this case the slash is just a separator
                consume(TokenType.SLASH, true);
            }
            parseStepExpr();
        }

    }
717864
public void setContextPath(String contextPath) {
		if (StringUtils.isNotEmpty(contextPath)) {
			if (contextPath.charAt(0) != '/') {
				contextPath = '/' + contextPath;
			}
			if (contextPath.charAt(contextPath.length() - 1) != '/') {
				contextPath = contextPath + '/';
			}
			this.contextPath = contextPath;
		} else {
			this.contextPath = null;
		}
	}
574105
private void registerPath(Path path, int maxDepth) {
		try {
			final WatchKey key = path.register(watchService, ArrayUtil.isEmpty(this.events) ? EVENTS_ALL : this.events);
			watchKeyPathMap.put(key, path);
			if(maxDepth > 1) {
				//遍历所有子目录并加入监听
				Files.walkFileTree(path, EnumSet.noneOf(FileVisitOption.class), maxDepth, new SimpleFileVisitor<Path>(){
					@Override
					public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
						registerPath(dir, 0);//继续添加目录
						return super.postVisitDirectory(dir, exc);
					}
				});
			}
		} catch (IOException e) {
			if(e instanceof AccessDeniedException) {
				//对于禁止访问的目录，跳过监听
				return;
			}
			throw new WatchException(e);
		}
	}
664537
public void setRelativePath(QPath relPath) {
        if (relPath != null && relPath.isAbsolute()) {
            throw new IllegalArgumentException("relPath must be relative");
        }
        this.relPath = relPath;
    }
550022
private void applyRelativePath(RelationQueryNode node) {
       if (tmpRelPath != null)
       {
          // try {
          QPath relPath = tmpRelPath;
          for (int i = 0; i < relPath.getEntries().length; i++)
          {
             node.addPathElement(relPath.getEntries()[i]);
          }
          tmpRelPath = null;
       }
    }
474620
public static void consumeSubFilePaths(Path startDirectoryPath,
			int maxDepth, Consumer<Path> consumer) {
		consumeSubFilePaths(startDirectoryPath, maxDepth, JMPredicate.getTrue(),
				consumer);
	}
255914
public void setDirectoryPath(String pidsfilepath) {
        File pidsfile = new File(pidsfilepath);
        directoryPath = pidsfile.getParent();
    }