Esempio n. 1
0
import sys
import os
import re
import collections
sys.path.append(
    os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg',
                 'scripts'))
import tree
import gcgtree

for line in sys.stdin:
    print(gcgtree.GCGTree(line))
import sys
import os
import re
import collections
sys.path.append(
    os.path.join(os.path.dirname(__file__), '..', '..', 'resource-gcg',
                 'scripts'))
import tree
import gcgtree

for line in sys.stdin:
    print(gcgtree.GCGTree(
        line.strip()))  #strip to prevent adding additional blank lines
      t.c += xy
    else:
      t.c += '-x%' + morph.getLemma(t.c,t.ch[0].c) + '|%Bot' 
  for st in t.ch:
    ctr = annotY( st, Ymap, ctr )
  return ctr

################################################################################
################################################################################

## read in corpus and convert to traversal trees...
lt       = [ ]
llpttrav = [ ]
for line in sys.stdin:
  Marked = { }
  lt.append( gcgtree.GCGTree(line) )
#  print( semcuegraph.StoreStateCueGraph(lt[-1]) )
  numberTerminals( lt[-1] )
  lptFactored = factorConj( lt[-1] )
  llpttrav.append( [ (p,t,makeTraversal(semcuegraph.SimpleCueGraph(semcuegraph.SemCueGraph(t)),Marked)) for p,t in lptFactored ] )
#  for p,t in lptFactored:
#    print( '==FULL==>', str( semcuegraph.SemCueGraph(t) ) )
#    print( '--SIMPLE->', str( semcuegraph.SimpleCueGraph(semcuegraph.SemCueGraph(t)) ) )

## set size params...
K,L = 0,0
for lpttrav in llpttrav:
  for p,t,trav in lpttrav:
    K,l = setKL( trav, KINTS )
    L = max(L,l)
sys.stderr.write( str(K) + ' predicate constants, ' + str(L) + ' dependency labels.\n' )
Esempio n. 4
0
  ## Define discourse graph...
  G = semcuegraph.SemCueGraph( )
  sentctr = 0

  ## For each sentence...
  for line in sys.stdin:

    if '!ARTICLE' in line: break

    if sentctr == 0:
      discctr += 1
      sys.stderr.write( 'Discourse ' + str(discctr) + ': ' + line )

    ## Initialize new tree with or without tree-lengthening...
    if RELABEL:
      t = gcgtree.GCGTree( line )
    else:
      t = tree.Tree( )
      t.read( line )
    ## Add tree to discourse graph...
    G.add( t, ('0' if sentctr<10 else '') + str(sentctr) )
    sentctr += 1

  else: finished = True

  ## If discourse contained any sentences, finalize and print graph...
  if sentctr>0:
    G.finalize()
    print( str(G) )