Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 9a425e4

Browse files
committed
Adjust whitespaces
1 parent b3a7911 commit 9a425e4

3 files changed

Lines changed: 467 additions & 455 deletions

File tree

src/main/java/com/formulasearchengine/mathmlquerygenerator/NtcirPattern.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@
66
* Created by Moritz Schubotz on 08.11.2014.
77
*/
88
public class NtcirPattern {
9-
private final String num;
10-
private final String formulaID;
11-
private final String xQueryExpression;
12-
private final Node mathMLNode;
9+
private final String num;
10+
private final String formulaID;
11+
private final String xQueryExpression;
12+
private final Node mathMLNode;
1313

14-
/**
15-
* @param num
16-
* @param formulaID
17-
* @param xQueryExpression
18-
* @param mathMLNode
19-
*/
20-
public NtcirPattern( String num, String formulaID, String xQueryExpression, Node mathMLNode ) {
21-
this.num = num;
22-
this.formulaID = formulaID;
23-
this.xQueryExpression = xQueryExpression;
24-
this.mathMLNode = mathMLNode;
25-
}
14+
/**
15+
* @param num
16+
* @param formulaID
17+
* @param xQueryExpression
18+
* @param mathMLNode
19+
*/
20+
public NtcirPattern(String num, String formulaID, String xQueryExpression, Node mathMLNode) {
21+
this.num = num;
22+
this.formulaID = formulaID;
23+
this.xQueryExpression = xQueryExpression;
24+
this.mathMLNode = mathMLNode;
25+
}
2626

27-
public final String getNum() {
28-
return num;
29-
}
27+
public final String getNum() {
28+
return num;
29+
}
3030

31-
public final String getFormulaID() {
32-
return formulaID;
33-
}
31+
public final String getFormulaID() {
32+
return formulaID;
33+
}
3434

35-
public final String getxQueryExpression() {
36-
return xQueryExpression;
37-
}
35+
public final String getxQueryExpression() {
36+
return xQueryExpression;
37+
}
3838

39-
public final Node getMathMLNode() {
40-
return mathMLNode;
41-
}
39+
public final Node getMathMLNode() {
40+
return mathMLNode;
41+
}
4242
}

src/main/java/com/formulasearchengine/mathmlquerygenerator/NtcirTopicReader.java

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -24,83 +24,85 @@
2424
* http://ntcir-math.nii.ac.jp/wp-content/blogs.dir/13/files/2014/05/NTCIR11-Math-topics.pdf
2525
*/
2626
public class NtcirTopicReader {
27-
public static final String NS_NII = "http://ntcir-math.nii.ac.jp/";
28-
private final Document topics;
29-
private final List<NtcirPattern> patterns = new ArrayList<>();
30-
private final XQueryGenerator queryGenerator;
27+
public static final String NS_NII = "http://ntcir-math.nii.ac.jp/";
28+
private final Document topics;
29+
private final List<NtcirPattern> patterns = new ArrayList<>();
30+
private final XQueryGenerator queryGenerator;
3131

32-
public NtcirTopicReader( Document topics ) {
33-
this.topics = topics;
34-
queryGenerator = new XQueryGenerator( topics );
35-
}
32+
public NtcirTopicReader(Document topics) {
33+
this.topics = topics;
34+
queryGenerator = new XQueryGenerator(topics);
35+
}
3636

37-
public NtcirTopicReader( File topicFile ) throws ParserConfigurationException, IOException, SAXException {
38-
DocumentBuilder documentBuilder = XMLHelper.getDocumentBuilder( true );
39-
topics = documentBuilder.parse( topicFile );
37+
public NtcirTopicReader(File topicFile) throws ParserConfigurationException, IOException, SAXException {
38+
DocumentBuilder documentBuilder = XMLHelper.getDocumentBuilder(true);
39+
topics = documentBuilder.parse(topicFile);
4040

41-
//TODO: Find out how this code duplication can be avoided in Java.
42-
queryGenerator = new XQueryGenerator( topics );
43-
}
41+
//TODO: Find out how this code duplication can be avoided in Java.
42+
queryGenerator = new XQueryGenerator(topics);
43+
}
4444

45-
public NtcirTopicReader( Document topics, String namespace, String pathToRoot, String returnFormat, boolean restrictLength ) {
46-
queryGenerator = new XQueryGenerator( topics );
47-
this.topics = topics;
48-
this.setNamespace(namespace).setReturnFormat(returnFormat).setPathToRoot(pathToRoot).setRestrictLength(restrictLength);
49-
}
45+
public NtcirTopicReader(Document topics, String namespace, String pathToRoot, String returnFormat, boolean restrictLength) {
46+
queryGenerator = new XQueryGenerator(topics);
47+
this.topics = topics;
48+
this.setNamespace(namespace).setReturnFormat(returnFormat).setPathToRoot(pathToRoot).setRestrictLength(restrictLength);
49+
}
5050

51-
public final NtcirTopicReader setReturnFormat(String returnFormat) {
52-
queryGenerator.setReturnFormat(returnFormat);
53-
return this;
54-
}
51+
public final NtcirTopicReader setReturnFormat(String returnFormat) {
52+
queryGenerator.setReturnFormat(returnFormat);
53+
return this;
54+
}
5555

56-
public final NtcirTopicReader setNamespace(String namespace) {
57-
queryGenerator.setNamespace(namespace);
58-
return this;
59-
}
56+
public final NtcirTopicReader setNamespace(String namespace) {
57+
queryGenerator.setNamespace(namespace);
58+
return this;
59+
}
6060

61-
public final NtcirTopicReader setPathToRoot(String pathToRoot) {
62-
queryGenerator.setPathToRoot(pathToRoot);
63-
return this;
64-
}
61+
public final NtcirTopicReader setPathToRoot(String pathToRoot) {
62+
queryGenerator.setPathToRoot(pathToRoot);
63+
return this;
64+
}
6565

66-
public final NtcirTopicReader setFindRootApply(boolean findRootApply) {
67-
queryGenerator.setFindRootApply(findRootApply);
68-
return this;
69-
}
66+
public final NtcirTopicReader setFindRootApply(boolean findRootApply) {
67+
queryGenerator.setFindRootApply(findRootApply);
68+
return this;
69+
}
7070

71-
public final NtcirTopicReader setRestrictLength( boolean restrictLength ) {
72-
queryGenerator.setRestrictLength( restrictLength );
73-
return this;
74-
}
71+
public final NtcirTopicReader setRestrictLength(boolean restrictLength) {
72+
queryGenerator.setRestrictLength(restrictLength);
73+
return this;
74+
}
7575

76-
public final NtcirTopicReader setAddQvarMap( boolean addQvarMap ) {
77-
queryGenerator.setAddQvarMap( addQvarMap );
78-
return this;
79-
}
76+
public final NtcirTopicReader setAddQvarMap(boolean addQvarMap) {
77+
queryGenerator.setAddQvarMap(addQvarMap);
78+
return this;
79+
}
8080

81-
/**
82-
* Splits the given NTCIR query file into individual queries, converts each query into an XQuery using
83-
* XQueryGenerator, and returns the result as a list of NtcirPatterns for each individual query.
84-
* @return List of NtcirPatterns for each query
85-
* @throws XPathExpressionException Thrown if xpaths fail to compile or fail to evaluate
86-
+ */
87-
public final List<NtcirPattern> extractPatterns() throws XPathExpressionException {
88-
final XPath xpath = XMLHelper.namespaceAwareXpath( "t", NS_NII );
89-
final XPathExpression xNum = xpath.compile( "./t:num" );
90-
final XPathExpression xFormula = xpath.compile( "./t:query/t:formula" );
91-
final NonWhitespaceNodeList topicList = new NonWhitespaceNodeList(
92-
topics.getElementsByTagNameNS( NS_NII, "topic" ) );
93-
for ( final Node node : topicList ) {
94-
final String num = xNum.evaluate( node );
95-
final NonWhitespaceNodeList formulae = new NonWhitespaceNodeList( (NodeList)
96-
xFormula.evaluate( node, XPathConstants.NODESET ) );
97-
for ( final Node formula : formulae ) {
98-
final String id = formula.getAttributes().getNamedItem( "id" ).getTextContent();
99-
final Node mathMLNode = getFirstChild( formula );
100-
queryGenerator.setMainElement( getFirstChild( mathMLNode ) );
101-
patterns.add( new NtcirPattern( num, id, queryGenerator.toString(), mathMLNode ) );
102-
}
103-
}
104-
return patterns;
105-
}
81+
/**
82+
* Splits the given NTCIR query file into individual queries, converts each query into an XQuery using
83+
* XQueryGenerator, and returns the result as a list of NtcirPatterns for each individual query.
84+
*
85+
* @return List of NtcirPatterns for each query
86+
* @throws XPathExpressionException Thrown if xpaths fail to compile or fail to evaluate
87+
* +
88+
*/
89+
public final List<NtcirPattern> extractPatterns() throws XPathExpressionException {
90+
final XPath xpath = XMLHelper.namespaceAwareXpath("t", NS_NII);
91+
final XPathExpression xNum = xpath.compile("./t:num");
92+
final XPathExpression xFormula = xpath.compile("./t:query/t:formula");
93+
final NonWhitespaceNodeList topicList = new NonWhitespaceNodeList(
94+
topics.getElementsByTagNameNS(NS_NII, "topic"));
95+
for (final Node node : topicList) {
96+
final String num = xNum.evaluate(node);
97+
final NonWhitespaceNodeList formulae = new NonWhitespaceNodeList((NodeList)
98+
xFormula.evaluate(node, XPathConstants.NODESET));
99+
for (final Node formula : formulae) {
100+
final String id = formula.getAttributes().getNamedItem("id").getTextContent();
101+
final Node mathMLNode = getFirstChild(formula);
102+
queryGenerator.setMainElement(getFirstChild(mathMLNode));
103+
patterns.add(new NtcirPattern(num, id, queryGenerator.toString(), mathMLNode));
104+
}
105+
}
106+
return patterns;
107+
}
106108
}

0 commit comments

Comments
 (0)