Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Carlos-Francisco Méndez-Cruz
/
conditional-random-fields
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Carlos-Francisco Méndez-Cruz
2019-02-14 14:02:22 -0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e286ce41339ac022cad80713e31a9f768077e656
e286ce41
1 parent
a86653d3
Conditional Random Fields
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
tagging_Sklearn_crfsuite.py
tagging_Sklearn_crfsuite.py
View file @
e286ce4
...
...
@@ -148,6 +148,27 @@ def word2features(sent, i):
'''
return
features
def
sent2features
(
sent
):
return
[
word2features
(
sent
,
i
)
for
i
in
range
(
len
(
sent
))]
def
sent2labels
(
sent
):
return
[
elem
.
split
(
'|'
)[
3
]
for
elem
in
sent
]
def
sent2tokens
(
sent
):
return
[
token
for
token
,
postag
,
label
in
sent
]
def
print_transitions
(
trans_features
,
f
):
for
(
label_from
,
label_to
),
weight
in
trans_features
:
f
.
write
(
"{:6} -> {:7} {:0.6f}
\n
"
.
format
(
label_from
,
label_to
,
weight
))
def
print_state_features
(
state_features
,
f
):
for
(
attr
,
label
),
weight
in
state_features
:
f
.
write
(
"{:0.6f} {:8} {}
\n
"
.
format
(
weight
,
label
,
attr
.
encode
(
"utf-8"
)))
__author__
=
'CMendezC'
##########################################
...
...
Please
register
or
login
to post a comment