Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
corpus2
Commits
5950f62c
Commit
5950f62c
authored
Jan 27, 2012
by
Adam Radziszewski
Browse files
Options
Downloads
Patches
Plain Diff
util for plain text exctraction
parent
1771a56c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/corpspace.py
+61
-0
61 additions, 0 deletions
utils/corpspace.py
with
61 additions
and
0 deletions
utils/corpspace.py
0 → 100755
+
61
−
0
View file @
5950f62c
#!/usr/bin/python
# -*- coding: utf-8 -*-
from
optparse
import
OptionParser
import
sys
import
corpus2
from
StringIO
import
StringIO
from
collections
import
defaultdict
as
dd
descr
=
"""
%prog [options] TAGOUT MORPHO OUT
Util to synchronise no-space markers between tagger output (TAGOUT) that
contains the wanted disamb lexemes but may be devoid of no-space markers
with the tagger input containing proper no-space markers but no disambs.
"""
def
go
():
parser
=
OptionParser
(
usage
=
descr
)
parser
.
add_option
(
'
-i
'
,
'
--input-format
'
,
type
=
'
string
'
,
action
=
'
store
'
,
dest
=
'
input_format
'
,
default
=
'
xces
'
,
help
=
'
set the input format; default: xces
'
)
parser
.
add_option
(
'
-o
'
,
'
--output-format
'
,
type
=
'
string
'
,
action
=
'
store
'
,
dest
=
'
output_format
'
,
default
=
'
xces
'
,
help
=
'
set the output format; default: xces
'
)
parser
.
add_option
(
'
-t
'
,
'
--tagset
'
,
type
=
'
string
'
,
action
=
'
store
'
,
dest
=
'
tagset
'
,
default
=
'
nkjp
'
,
help
=
'
set the tagset used in input; default: nkjp
'
)
parser
.
add_option
(
'
-q
'
,
'
--quiet
'
,
action
=
'
store_false
'
,
default
=
True
,
dest
=
'
verbose
'
)
parser
.
add_option
(
'
-d
'
,
'
--debug
'
,
action
=
'
store_true
'
,
dest
=
'
debug_mode
'
)
(
options
,
args
)
=
parser
.
parse_args
()
if
len
(
args
)
!=
3
:
print
'
You need to provide a TAGOUT, MORPHO and OUTPUT files.
'
print
'
See --help for details.
'
print
sys
.
exit
(
1
)
tag_fn
,
mor_fn
,
out_fn
=
args
tagset
=
corpus2
.
get_named_tagset
(
options
.
tagset
)
tag_rdr
=
corpus2
.
TokenReader
.
create_path_reader
(
options
.
input_format
,
tagset
,
tag_fn
)
mor_rdr
=
corpus2
.
TokenReader
.
create_path_reader
(
options
.
input_format
,
tagset
,
mor_fn
)
writer
=
corpus2
.
TokenWriter
.
create_path_writer
(
options
.
output_format
,
out_fn
,
tagset
)
while
True
:
mor_sent
=
mor_rdr
.
get_next_sentence
()
tag_sent
=
tag_rdr
.
get_next_sentence
()
assert
(
not
mor_sent
)
==
(
not
tag_sent
)
if
not
mor_sent
:
break
for
mor_tok
,
tag_tok
in
zip
(
mor_sent
.
tokens
(),
tag_sent
.
tokens
()):
assert
unicode
(
mor_tok
.
orth
())
==
unicode
(
tag_tok
.
orth
()),
unicode
(
tag_tok
.
orth
())
tag_tok
.
set_wa
(
mor_tok
.
wa
())
writer
.
write_sentence
(
tag_sent
)
writer
.
finish
()
if
__name__
==
'
__main__
'
:
go
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment