当前位置: 首页>>代码示例>>Java>>正文


Java MathTokenizer类代码示例

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


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

示例1: process

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
private MIaSTermContainer process(String query) throws IOException {
    System.out.println(query);
    List<MIaSTerm> result = new ArrayList<>();
    String mathQuery = "<html>" + query + "</html>";
    MathTokenizer mt = new MathTokenizer(new StringReader(mathQuery), true, MathTokenizer.MathMLType.BOTH);
    mt.reset();
    Map<Integer, List<Formula>> forms = mt.getFormulae();
    for (int i = 0; i < forms.size(); i++) {
        List<Formula> flist = forms.get(i);
        for (Formula f : flist) {
            result.add(new MIaSTerm(Formula.nodeToString(f.getNode(), false, MathMLConf.getElementDictionary(), MathMLConf.getAttrDictionary(), MathMLConf.getIgnoreNode()), f.getWeight()));
        }
    }
    MIaSTermContainer fc = new MIaSTermContainer();
    fc.setForms(result);
    return fc;
}
 
开发者ID:martinliska,项目名称:WebMIaS,代码行数:18,代码来源:MtermResource.java

示例2: processRequest

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("application/json;charset=UTF-8");

    String query = request.getParameter("mathml");

    List<MIaSTerm> result = new ArrayList<>();
    String mathQuery = "<html>" + query + "</html>";
    MathTokenizer mt = new MathTokenizer(new StringReader(mathQuery), true, MathTokenizer.MathMLType.BOTH);
    Map<Integer, List<Formula>> forms = mt.getFormulae();
    for (int i = 0; i < forms.size(); i++) {
        List<Formula> flist = forms.get(i);
        for (Formula f : flist) {
            result.add(new MIaSTerm(Formula.nodeToString(f.getNode(), false, MathMLConf.getElementDictionary(), MathMLConf.getAttrDictionary(), MathMLConf.getIgnoreNode()), f.getWeight()));
        }
    }
    MIaSTermContainer fc = new MIaSTermContainer();
    fc.setForms(result);

    StringWriter sw = new StringWriter();
    JsonMarshallHelper.marshall(fc, sw);

    response.getWriter().write(sw.toString());
}
 
开发者ID:martinliska,项目名称:WebMIaS,代码行数:25,代码来源:MtermServlet.java

示例3: getType

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
private MathTokenizer.MathMLType getType(String variant) {
    if (variant == null) {
        return MathTokenizer.MathMLType.BOTH;
    }
    if (variant.equals("pmath")) {
        return MathTokenizer.MathMLType.PRESENTATION;
    }
    if (variant.equals("cmath")) {
        return MathTokenizer.MathMLType.CONTENT;
    }
    return MathTokenizer.MathMLType.BOTH;
}
 
开发者ID:martinliska,项目名称:WebMIaS,代码行数:13,代码来源:ProcessServlet.java

示例4: printTimes

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
private void printTimes() {
    LOG.info("---------------------------------");
    LOG.info(Settings.EMPTY_STRING);
    LOG.info("{} DONE in total time {} ms",progress,System.currentTimeMillis() - startTime);
    LOG.info("CPU time {} ms",getCpuTime());
    LOG.info("user time {} ms",getUserTime());
    MathTokenizer.printFormulaeCount(); // TODO
    LOG.info(Settings.EMPTY_STRING);
}
 
开发者ID:martinliska,项目名称:MIaS,代码行数:10,代码来源:Indexing.java

示例5: getDocuments

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
@Override
public List<Document> getDocuments() throws IOException {
    Document document = source.createDocument();
    
    HtmlDocumentExtractor htmldoc = new HtmlDocumentExtractor(source.resetStream());

    String arxivId = htmldoc.getArxivId();
    if (arxivId != null) {
        document.removeField("id");
        Field arxivIdField = new StringField("id", arxivId, Field.Store.YES);
        document.add(arxivIdField);
    }

    String title = htmldoc.getTitle();
    if (title != null) {
        document.removeField("title");
        Field titleField = new TextField("title", title, Field.Store.YES);
        titleField.setBoost(Float.parseFloat("10.0"));
        document.add(titleField);
    }

    String authors = htmldoc.getAuthors();
    if (authors != null) {
        Field authorsField = new StringField("authors", authors, Field.Store.YES);
        authorsField.setBoost(Float.parseFloat("10.0"));
        document.add(authorsField);
    }
    
    String content = htmldoc.getBody();
    if (content != null) {
        document.add(new TextField("content", content, Field.Store.NO));
    }

    InputStreamReader isr = new InputStreamReader(source.resetStream(), "UTF-8");
    document.add(new TextField("pmath", new MathTokenizer(isr, true, MathTokenizer.MathMLType.PRESENTATION)));
    isr = new InputStreamReader(source.resetStream(), "UTF-8");
    document.add(new TextField("cmath", new MathTokenizer(isr, true, MathTokenizer.MathMLType.CONTENT)));
    
    return Arrays.asList(document);
}
 
开发者ID:martinliska,项目名称:MIaS,代码行数:41,代码来源:HtmlDocument.java

示例6: addMathQueries

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
private Map<String, Float> addMathQueries(String mathQuery, BooleanQuery bq, MathTokenizer.MathMLType variant, boolean extractSubformulae, boolean reduceWeighting) {
    MathTokenizer mt = new MathTokenizer(new StringReader(mathQuery), extractSubformulae, variant, reduceWeighting);
    try {
        mt.reset();
    } catch (IOException ex) {
        LOG.fatal(ex);
    }
    Map<String, Float> queryForms = mt.getQueryFormulae();
    List<Query> cQueries = getMathQueries(queryForms, variant);
    for (Query q : cQueries) {
        bq.add(q, BooleanClause.Occur.SHOULD);
    }
    return mt.getQueryXMLFormulae();
}
 
开发者ID:martinliska,项目名称:MIaS,代码行数:15,代码来源:Searching.java

示例7: getMathQueries

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
private List<Query> getMathQueries(Map<String, Float> queryForms, MathTokenizer.MathMLType type) {
    String field = (type == MathTokenizer.MathMLType.PRESENTATION ? "p" : "c") + "math";
    List<Query> result = new ArrayList<>();
    Iterator<Map.Entry<String, Float>> it = queryForms.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, Float> entry = it.next();
        Float boost = entry.getValue();
        PayloadTermQuery ptq = new PayloadTermQuery(new Term(field, entry.getKey()), new AveragePayloadFunction());

        ptq.setBoost(boost);
        result.add(ptq);
    }
    return result;
}
 
开发者ID:martinliska,项目名称:MIaS,代码行数:15,代码来源:Searching.java

示例8: create

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
@Override
public Tokenizer create(AttributeFactory af, Reader reader) {
    return new MathTokenizer(reader, subformulae, MathTokenizer.MathMLType.BOTH);
}
 
开发者ID:martinliska,项目名称:MIaSMath,代码行数:5,代码来源:MathTokenizerFactory.java

示例9: getDocuments

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
@Override
public List<Document> getDocuments() throws IOException {
    List<Document> result = new ArrayList<>();
    try {
        DocumentBuilder builder = MIaSUtils.prepareDocumentBuilder();
        org.w3c.dom.Document document = builder.parse(source.resetStream());
        NodeList list = document.getElementsByTagNameNS("*", "math");
        for (int i = 0; i < list.getLength(); i++) {
            Node item = list.item(i);
            String id;
            Node namedItem = item.getAttributes().getNamedItem("id");
            if (namedItem != null) {
                id = namedItem.getNodeValue();
            } else {
                id = String.valueOf(i);
            }
            Document doc = source.createDocument();
            id = doc.get("id") + "#" + id;
            doc.removeField("id");
            doc.add(new StringField("id", id, Field.Store.YES));
            doc.removeField("title");
            doc.add(new TextField("title", id, Field.Store.YES));
            
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            Source xmlSource = new DOMSource(item);
            Result outputTarget = new StreamResult(outputStream);
            TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
            InputStream is = new ByteArrayInputStream(outputStream.toByteArray());
            InputStreamReader isr = new InputStreamReader(is, "UTF-8");
            MathTokenizer mathTokenizer = new MathTokenizer(isr, true, MathTokenizer.MathMLType.PRESENTATION);
            mathTokenizer.setFormulaPosition(i+1);
            doc.add(new TextField("pmath", mathTokenizer));
            is.reset();
            isr = new InputStreamReader(is, "UTF-8");
            MathTokenizer mathTokenizer1 = new MathTokenizer(isr, true, MathTokenizer.MathMLType.CONTENT);
            mathTokenizer1.setFormulaPosition(i+1);
            doc.add(new TextField("cmath", mathTokenizer1));
            result.add(doc);
        }
    } catch (TransformerException | SAXException | ParserConfigurationException ex) {
        LOG.fatal(ex);
    }
    return result;
}
 
开发者ID:martinliska,项目名称:MIaS,代码行数:45,代码来源:FormulaDocument.java

示例10: search

import cz.muni.fi.mias.math.MathTokenizer; //导入依赖的package包/类
public SearchResult search(String query, boolean print, int offset, int limit, boolean debug, MathTokenizer.MathMLType variant) {
    return search(query, print, offset, limit, debug, variant, false);
}
 
开发者ID:martinliska,项目名称:MIaS,代码行数:4,代码来源:Searching.java


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