Beispiel #1
0
def test_threadslot():
    print 'parser.ThreadSlot contents:', dir(parser.ThreadSlot)
    print
    z = parser.ThreadSlot()
    print z
    print z.acquiredThreadSlot()
    print z.recycle()
    print z.acquiredThreadSlot()
    print z.acquire()
    print z.acquiredThreadSlot()
Beispiel #2
0
 def __init__(self):
     self._parser_model_loaded = False
     self._reranker_model = None
     self._parser_thread_slot = parser.ThreadSlot()
Beispiel #3
0
        ext_pos.addTagConstraints(parser.VectorString([]))
        ext_pos.addTagConstraints(parser.VectorString([]))
        ext_pos.addTagConstraints(parser.VectorString([]))
        display_parses(parser.parse(sr1, ext_pos, thread_slot))


def test_threadslot():
    print 'parser.ThreadSlot contents:', dir(parser.ThreadSlot)
    print
    z = parser.ThreadSlot()
    print z
    print z.acquiredThreadSlot()
    print z.recycle()
    print z.acquiredThreadSlot()
    print z.acquire()
    print z.acquiredThreadSlot()


if __name__ == "__main__":
    thread_slot = parser.ThreadSlot()
    dir_contents()
    if 1:
        initialize(n=5)
        test_as_nbest_list()
        for x in range(1000):  # memory leak detection
            print 'iteration', x
            test_tokenizer()
            test_parse()
            test_multiword_extpos()
            test_extpos()
Beispiel #4
0
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
# License for the specific language governing permissions and limitations
# under the License.

import SWIGParser
import fileinput

if __name__ == "__main__":
    from test import initialize, display_parses
    thread_slot = SWIGParser.ThreadSlot()
    initialize(n=50)
    for line in fileinput.input():
        line = line.strip()

        print line
        tree = SWIGParser.inputTreeFromString('(S1 ' + line + ')')
        print tree
        sentence = tree.toSentRep()
        print sentence
        parses = SWIGParser.parse(sentence, thread_slot)
        print len(parses), 'parses'
        if not parses:
            raise 'failed'
        display_parses(parses)
        print 'example failure tree', sentence.makeFailureTree(