~denys.duchier/crftagger/crotal

« back to all changes in this revision

Viewing changes to crotal

  • Committer: Denys Duchier
  • Date: 2011-04-20 21:07:39 UTC
  • Revision ID: denys.duchier@univ-orleans.fr-20110420210739-6p4r6n2ci7iemxym
corpus transformations work

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
def cmd_corpus(args):
33
33
    import libcrotal.corpus
34
 
    libcrotal.corpus.XXX
 
34
    libcrotal.corpus.run(args)
35
35
 
36
36
def cmd_pattern(args):
37
37
    import libcrotal.pattern
130
130
#
131
131
# crotal corpus -o FILE [--command=CMD]* CORPUS
132
132
# Possible CMD:
133
 
#     delete:I          delete column I
134
 
#     prefix:I          add column with prefix of length (at most) I
135
 
#     prefix:-I         add column with suffix of length (at most) I removed
136
 
#     suffix:I          add column with suffix of length (at most) I
137
 
#     suffix:-I         add column with prefix of length (at most) I removed
138
 
#     punct             add column with 0/1 if there is a punctuation
139
 
#     digit             add column with 0/1 if there is a digit
140
 
#     capitalized       add column with 0/1 if starts with an upper case letter
141
 
#     uppercase         add column with 0/1 if all letters are uppercase
 
133
#     delete:COL        delete column COL
 
134
#     prefix:N[:COL]    add column with prefix of length (at most) N
 
135
#     prefix:-N[:COL]   add column with suffix of length (at most) N removed
 
136
#     suffix:N[:COL]    add column with suffix of length (at most) N
 
137
#     suffix:-N[:COL]   add column with prefix of length (at most) N removed
 
138
#     punctuation[:COL] add column with 0/1 if there is a punctuation
 
139
#     digit[:COL]       add column with 0/1 if there is a digit
 
140
#     capitalized[:COL] add column with 0/1 if starts with an upper case letter
 
141
#     uppercase[:COL]   add column with 0/1 if all letters are uppercase
142
142
#
143
143
# prefix and suffix are implicitly "to lower".
144
144
#==============================================================================
148
148
corpus.set_defaults(func=cmd_corpus)
149
149
 
150
150
corpus.add_argument(
151
 
    "-o", "--output", type=FileInExistingDir, metavar="FILE", required=True,
152
 
    help="output corpus")
 
151
    "-o", "--output", type=argparse.FileType("wb"), metavar="FILE",
 
152
    default=None,
 
153
    help="output corpus (default: stdout)")
153
154
corpus.add_argument(
154
 
    "corpus", nargs=1, type=ExistingFile, metavar="CORPUS",
155
 
    help="input corpus")
 
155
    "corpus", nargs='?', type=argparse.FileType("rUb"), metavar="CORPUS",
 
156
    default=None,
 
157
    help="input corpus (default: stdin)")
156
158
corpus.add_argument(
157
159
    "-c", "--command", metavar="CMD", action="append",
158
160
    help="elementary transformation to apply to the corpus")