Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Shallow-Parser-Evaluation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pruthwik mishra
Shallow-Parser-Evaluation
Commits
336b31bb
Commit
336b31bb
authored
May 05, 2022
by
pruthwik mishra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conversion of pos tags from BIS to ILMT
parent
6ae59504
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
Code/convert_bis_pos_tag_to_ilmt.py
Code/convert_bis_pos_tag_to_ilmt.py
+97
-0
No files found.
Code/convert_bis_pos_tag_to_ilmt.py
0 → 100644
View file @
336b31bb
from
re
import
search
from
sys
import
argv
def
bis_to_ilmt_conversion
(
bis_pos_tag
):
"""Convert a BIS pos tag to ILMT pos tag."""
ilmt_tag
=
''
bis_pos_tag
=
bis_pos_tag
.
replace
(
'__'
,
'_'
)
if
bis_pos_tag
==
'N_NNV'
:
ilmt_tag
=
'VM'
elif
search
(
'N_(N.*)'
,
bis_pos_tag
):
print
(
search
(
'N_(N.*)'
,
bis_pos_tag
))
ilmt_tag
=
search
(
'N_(N.*)'
,
bis_pos_tag
).
group
(
1
)
elif
bis_pos_tag
==
'PR_PRQ'
:
ilmt_tag
=
'WQ'
elif
search
(
'PR_PR.*'
,
bis_pos_tag
):
ilmt_tag
=
'PRP'
elif
search
(
'DM_.*'
,
bis_pos_tag
):
ilmt_tag
=
'DEM'
elif
search
(
'V_VM.*'
,
bis_pos_tag
):
ilmt_tag
=
'VM'
elif
bis_pos_tag
==
'JJ'
:
ilmt_tag
=
'JJ'
elif
bis_pos_tag
==
'RB'
:
ilmt_tag
=
'RB'
elif
bis_pos_tag
==
'PSP'
:
ilmt_tag
=
'PSP'
elif
search
(
'V_VAUX'
,
bis_pos_tag
):
ilmt_tag
=
'VAUX'
elif
bis_pos_tag
==
'CC_CCS_UT'
:
ilmt_tag
=
'UT'
elif
search
(
'CC.*'
,
bis_pos_tag
):
ilmt_tag
=
'CC'
elif
bis_pos_tag
==
'RP_RPD'
:
ilmt_tag
=
'RP'
elif
search
(
'RP_(.+)'
,
bis_pos_tag
):
ilmt_tag
=
search
(
'RP_(.+)'
,
bis_pos_tag
).
group
(
1
)
elif
search
(
'QT.*'
,
bis_pos_tag
):
if
bis_pos_tag
[
-
1
]
==
'F'
:
ilmt_tag
=
'QF'
elif
bis_pos_tag
[
-
1
]
==
'C'
:
ilmt_tag
=
'QC'
elif
bis_pos_tag
[
-
1
]
==
'O'
:
ilmt_tag
=
'QO'
elif
bis_pos_tag
in
[
'RD_PUNC'
,
'RD_SYM'
]:
ilmt_tag
=
'SYM'
elif
bis_pos_tag
==
'RD_ECH'
:
ilmt_tag
=
'ECH'
elif
bis_pos_tag
==
'RD_RDF'
:
ilmt_tag
=
'FW'
elif
bis_pos_tag
==
'RD_UNK'
:
ilmt_tag
=
'UNK'
if
not
ilmt_tag
:
print
(
'BLANK'
)
ilmt_tag
=
'NN'
return
ilmt_tag
def
read_lines_from_file
(
file_path
):
"""Read lines from a file."""
with
open
(
file_path
,
'r'
,
encoding
=
'utf-8'
)
as
file_read
:
return
file_read
.
readlines
()
def
write_lines_into_file
(
lines
,
file_path
):
"""Write lines into a file."""
with
open
(
file_path
,
'w'
,
encoding
=
'utf-8'
)
as
file_write
:
file_write
.
write
(
'
\n
'
.
join
(
lines
))
def
convert_pos_tags_from_bis_to_ilmt
(
lines
):
"""Convert BIS pos tags into ILMT tags."""
converted_lines
=
list
()
for
line
in
lines
:
if
line
.
strip
():
line_split
=
line
.
strip
().
split
(
'
\t
'
)
ilmt_tag
=
bis_to_ilmt_conversion
(
line_split
[
1
])
if
len
(
line_split
)
==
2
:
converted_lines
.
append
(
'
\t
'
.
join
([
line_split
[
0
],
ilmt_tag
]))
else
:
converted_lines
.
append
(
'
\t
'
.
join
([
line_split
[
0
],
ilmt_tag
,
line_split
[
2
]]))
else
:
converted_lines
.
append
(
line
.
strip
())
return
converted_lines
def
main
():
"""Pass arguments and call functions here."""
input_file
=
argv
[
1
]
output_file
=
argv
[
2
]
input_lines
=
read_lines_from_file
(
input_file
)
converted_lines
=
convert_pos_tags_from_bis_to_ilmt
(
input_lines
)
write_lines_into_file
(
converted_lines
,
output_file
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment