348 |
348 |
@Parameter(key = CooccurrencePreferences.STRUCTURAL_UNIT_LIMIT, electric = false)
|
349 |
349 |
protected StructuralUnit pStructuralUnitLimit;
|
350 |
350 |
|
|
351 |
private CQLQuery fixedQuery;
|
351 |
352 |
|
352 |
353 |
/**
|
353 |
354 |
* Creates a not computed cooccurrence from the specified corpus.
|
... | ... | |
1490 |
1491 |
public boolean stepGetMatches() throws CqiClientException {
|
1491 |
1492 |
|
1492 |
1493 |
CQPCorpus corpus = this.getCorpus();
|
1493 |
|
QueryResult r1 = corpus.query(pQuery, "CoocFocusQuery", false); // keywords positions //$NON-NLS-1$
|
|
1494 |
QueryResult r1 = corpus.query(fixedQuery, "CoocFocusQuery", false); // keywords positions //$NON-NLS-1$
|
1494 |
1495 |
QueryResult r2 = null;
|
1495 |
|
if (contextQuery.equals(pQuery.fixQuery(this.getCorpus().getLang()))) {
|
|
1496 |
if (contextQuery.equals(fixedQuery)) {
|
1496 |
1497 |
r2 = r1;
|
1497 |
1498 |
}
|
1498 |
1499 |
else {
|
1499 |
1500 |
r2 = corpus.query(contextQuery, "CoocContextFocusQuery", false); // max context //$NON-NLS-1$
|
1500 |
1501 |
}
|
1501 |
1502 |
QueryResult r3 = null;
|
1502 |
|
if (anticontextquery.equals(pQuery.fixQuery(this.getCorpus().getLang()))) {
|
|
1503 |
if (anticontextquery.equals(fixedQuery)) {
|
1503 |
1504 |
r3 = r1;
|
1504 |
1505 |
}
|
1505 |
1506 |
else if (contextQuery.equals(anticontextquery)) {
|
... | ... | |
1514 |
1515 |
m2 = r2.getMatches();
|
1515 |
1516 |
m3 = r3.getMatches();
|
1516 |
1517 |
|
1517 |
|
if (debug) System.out.println(pQuery);
|
|
1518 |
if (debug) System.out.println(fixedQuery);
|
1518 |
1519 |
if (debug) System.out.println(m1);
|
1519 |
1520 |
if (debug) System.out.println(contextQuery);
|
1520 |
1521 |
if (debug) System.out.println(m2);
|
... | ... | |
1612 |
1613 |
public boolean stepQueryLimits() {
|
1613 |
1614 |
// structural context
|
1614 |
1615 |
|
1615 |
|
String fixedQuery = CQLQuery.fixQuery(pQuery.getQueryString(), this.getCorpus().getLang()); // a query starting with " or [ or (
|
1616 |
|
if (fixedQuery.contains("@[") || fixedQuery.contains("@\"")) {
|
|
1616 |
String sfixedQuery = CQLQuery.fixQuery(pQuery.getQueryString(), this.getCorpus().getLang()); // a query starting with " or [ or (
|
|
1617 |
if (sfixedQuery.contains("@[") || sfixedQuery.contains("@\"")) {
|
1617 |
1618 |
|
1618 |
|
} else if (fixedQuery.startsWith("(")) {
|
1619 |
|
fixedQuery = "(@"+fixedQuery.substring(1);
|
1620 |
|
} else if (fixedQuery.startsWith("((")) {
|
1621 |
|
fixedQuery = "((@"+fixedQuery.substring(2);
|
|
1619 |
} else if (sfixedQuery.startsWith("(")) {
|
|
1620 |
sfixedQuery = "(@"+sfixedQuery.substring(1);
|
|
1621 |
} else if (sfixedQuery.startsWith("((")) {
|
|
1622 |
sfixedQuery = "((@"+sfixedQuery.substring(2);
|
1622 |
1623 |
} else {
|
1623 |
|
fixedQuery = "@"+fixedQuery;
|
|
1624 |
sfixedQuery = "@"+sfixedQuery;
|
1624 |
1625 |
}
|
1625 |
1626 |
|
1626 |
1627 |
if (pStructuralUnitLimit != null) {
|
... | ... | |
1632 |
1633 |
tempquery += "(<" + lname + ">[]* </" + lname + ">){" + (pMaxLeftContextSize) + "," + (pMaxLeftContextSize) + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
1633 |
1634 |
}
|
1634 |
1635 |
// (<p>[]*</p>){0, 50} "je" (<p>[]*</p>){0, 50}
|
1635 |
|
tempquery += " <" + lname + ">[]* " + fixedQuery + " []* </" + lname + "> "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
1636 |
tempquery += " <" + lname + ">[]* " + sfixedQuery + " []* </" + lname + "> "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
1636 |
1637 |
|
1637 |
1638 |
// test if there is a right context
|
1638 |
1639 |
if (pMinRightContextSize > 0) {
|
... | ... | |
1646 |
1647 |
if (pMinLeftContextSize > 1) {
|
1647 |
1648 |
anticontextquerystring += "(<" + lname + ">[]* </" + lname + ">){" + (pMinLeftContextSize - 1) + "," + (pMinLeftContextSize - 1) + "} <" + lname + ">[]* "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
1648 |
1649 |
}
|
1649 |
|
anticontextquerystring += fixedQuery;
|
|
1650 |
anticontextquerystring += sfixedQuery;
|
1650 |
1651 |
// minright = 2..N
|
1651 |
1652 |
if (pMinRightContextSize > 1) {
|
1652 |
1653 |
anticontextquerystring += " []* </" + lname + "> (<" + lname + ">[]* </" + lname + ">){" + (pMinRightContextSize - 1) + "," + (pMinRightContextSize - 1) + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
... | ... | |
1659 |
1660 |
if (pMinLeftContextSize > 0) {
|
1660 |
1661 |
anticontextquerystring += "(<" + lname + ">[]* </" + lname + ">){" + (pMinLeftContextSize - 1) + "," + (pMinLeftContextSize - 1) + "} <" + lname + ">[]* "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
1661 |
1662 |
}
|
1662 |
|
anticontextquerystring += fixedQuery;
|
|
1663 |
anticontextquerystring += sfixedQuery;
|
1663 |
1664 |
// minright = 2..N
|
1664 |
1665 |
if (pMinRightContextSize > 0) {
|
1665 |
1666 |
anticontextquerystring += " []* </" + lname + "> (<" + lname + ">[]* </" + lname + ">){" + (pMinRightContextSize - 1) + "," + (pMinRightContextSize - 1) + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
... | ... | |
1673 |
1674 |
if (pMinLeftContextSize > 0) { // test if there is a left context
|
1674 |
1675 |
tempquery += "[]{" + pMaxLeftContextSize + "," + pMaxLeftContextSize + "} "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
1675 |
1676 |
}
|
1676 |
|
tempquery += fixedQuery;
|
|
1677 |
tempquery += sfixedQuery;
|
1677 |
1678 |
|
1678 |
1679 |
if (pMinRightContextSize > 0) { // test if there is a right context
|
1679 |
1680 |
tempquery += " []{" + pMaxRightContextSize + "," + pMaxRightContextSize + "} "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
... | ... | |
1683 |
1684 |
if (pMinLeftContextSize > 1) {
|
1684 |
1685 |
anticontextquerystring += "[]{" + (pMinLeftContextSize - 1) + ", " + (pMinLeftContextSize - 1) + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
1685 |
1686 |
}
|
1686 |
|
anticontextquerystring += fixedQuery;
|
|
1687 |
anticontextquerystring += sfixedQuery;
|
1687 |
1688 |
if (pMinRightContextSize > 1) {
|
1688 |
1689 |
anticontextquerystring += "[]{" + (pMinRightContextSize - 1) + "," + (pMinRightContextSize - 1) + "} "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
1689 |
1690 |
}
|
1690 |
1691 |
this.anticontextquery = new CQLQuery(anticontextquerystring);
|
1691 |
1692 |
}
|
|
1693 |
|
|
1694 |
fixedQuery = new CQLQuery(sfixedQuery);
|
|
1695 |
//fixedQuery = pQuery;
|
1692 |
1696 |
return true;
|
1693 |
1697 |
}
|
1694 |
1698 |
|
... | ... | |
1716 |
1720 |
public boolean toTxt(Writer writer, String colseparator, String txtseparator) {
|
1717 |
1721 |
try {
|
1718 |
1722 |
// Occ Freq CoFreq Score MeanDist
|
1719 |
|
writer.write(txtseparator + CooccurrenceCoreMessages.occ + txtseparator + colseparator +
|
|
1723 |
writer.write(
|
|
1724 |
txtseparator + CooccurrenceCoreMessages.occ + txtseparator + colseparator +
|
1720 |
1725 |
txtseparator + CooccurrenceCoreMessages.freq + txtseparator + colseparator +
|
1721 |
1726 |
txtseparator + CooccurrenceCoreMessages.coFreq + txtseparator + colseparator +
|
1722 |
1727 |
txtseparator + CooccurrenceCoreMessages.score + txtseparator + colseparator +
|