diff --git a/common/search_retrieve.py b/common/search_retrieve.py index 4738e17fc5193b5be0eb88ddc9d1f6fce3ed4dcb..b04d523b486267cb8dc2fc8e02e125adf7a09109 100644 --- a/common/search_retrieve.py +++ b/common/search_retrieve.py @@ -45,6 +45,7 @@ class Record: }) return record + if __name__ == '__main__': pass diff --git a/common/tsakorpus_query_parser.py b/common/tsakorpus_query_parser.py index abfe9d3e540f88078533942bcc78eca4305935aa..7ea8e10858f4a18a925348b6f88ec1077b8eb2a5 100644 --- a/common/tsakorpus_query_parser.py +++ b/common/tsakorpus_query_parser.py @@ -6,6 +6,7 @@ from .query_parser import QueryParser from .config import ResourceConfig from .diagnostics import Diagnostic, DiagnosticTypes + class TsakorpusQueryParser(QueryParser): """ Parses search queries for Tsakorpus-based corpora. diff --git a/common/tsakorpus_response_parser.py b/common/tsakorpus_response_parser.py index 68b8d2923aec437f58daf9ab1e41a42d69c86adf..7658d681fbfc67f760d163317169f3d2c7a998f9 100644 --- a/common/tsakorpus_response_parser.py +++ b/common/tsakorpus_response_parser.py @@ -27,6 +27,14 @@ class TsakorpusResponseParser: lemmasStr = '_' pos = set() posStr = '_' + word = '' + wordNodes = annoTree.xpath('div[@class="popup_word"]/span[@class="popup_wf"]') + for node in wordNodes: + if node.text is not None: + if len(word) > 0: + # This should not happen, but just in case + word += '|' + word += node.text lexNodes = annoTree.xpath('div[@class="popup_word"]/div[@class="popup_ana"]/span[@class="popup_lex"]') for node in lexNodes: if node.text is not None: @@ -42,6 +50,13 @@ class TsakorpusResponseParser: if len(pos) > 0: posStr = '|'.join(p for p in sorted(pos)) + if 'word' not in record.layers: + record.layers['word'] = [] + record.layers['word'].append({ + 'ref': segID, + 'value': word + }) + if 'pos' not in record.layers: record.layers['pos'] = [] record.layers['pos'].append({ diff --git a/test_queries.txt b/test_queries.txt new file mode 100644 index 0000000000000000000000000000000000000000..c9143d0961971fd91111622f5d61f99fa652e0cf --- /dev/null +++ b/test_queries.txt @@ -0,0 +1,10 @@ +http://127.0.0.1:5000/fcs-endpoint/flc Implicit explain +http://127.0.0.1:5000/fcs-endpoint/flc?operation=explain Explicit explain +http://127.0.0.1:5000/fcs-endpoint/flc?operation=searchRetrieve&query=regnum%20domni Formulae -- Simple search ("regnum domni", 11 hits) +http://127.0.0.1:5000/fcs-endpoint/flc?operation=searchRetrieve&query=regnum%20domni%20AND%20in Formulae -- Simple search with boolean operator ("regnum domni" AND "in", 6 hits) +http://127.0.0.1:5000/fcs-endpoint/flc?operation=searchRetrieve&query=regnum%20OR%20dominus Formulae -- Simple search with boolean operator ("regnum" OR "dominus", 815 hits) +http://127.0.0.1:5000/fcs-endpoint/test?operation=searchRetrieve&query=ke%20OR%20no Tsakorpus -- Simple search with boolean operator ("ke" OR "no") +http://127.0.0.1:5000/fcs-endpoint/test?operation=searchRetrieve&query=ke%20AND%20no Tsakorpus -- Simple search with boolean operator ("ke" AND "no", 103 hits) +http://127.0.0.1:5000/fcs-endpoint/test?operation=searchRetrieve&query=ke%20no Tsakorpus -- Simple search with multiple words ("ke no", 18 hits) +http://127.0.0.1:5000/fcs-endpoint/test?operation=searchRetrieve&query=ke%20no Tsakorpus -- Simple search with multiple words ("ke no", 18 hits) +http://127.0.0.1:5000/fcs-endpoint/test?operation=searchRetrieve&query=ke%20AND%20no&x-fcs-dataviews=adv Tsakorpus -- Simple search with boolean operator, advanced view ("ke" AND "no", 103 hits)